A truncated API key exposed a significant error-handling omission in Temporal-backed agent examples, causing authentication failures to be reported as successful workflow completions. The issue, discovered by developer byhashdong, demonstrated that a rejected API request could result in a normal return value from the Workflow, effectively masking the underlying infrastructure failure.

The Ambiguity of Result Messages

The affected samples utilized the Claude Agent SDK within Temporal's integration framework, where response loops awaited a ResultMessage and returned message.result directly. This design flaw meant that when the API rejected a request, the resulting string containing the error explanation was treated as a valid terminal result. Temporal had no mechanism to infer that a string returned by application code represented a failure rather than a successful answer. The structured-output example exhibited a different but related symptom, raising a misleading error about missing output when the actual cause was an authentication failure. This occurred because the code attempted to parse structured data before verifying the turn's success status, obscuring the root cause of the data absence.

Reproducing the Failure Offline

To isolate the issue without relying on live model inference, the developer extended existing local API fixtures to return HTTP 401 authentication errors. By configuring the test environment to use fixed test messages and local endpoints, the regression tests could deterministically trigger the failure path. Prior to the fix, nine out of ten test cases incorrectly treated error text as a successful result, while the structured-output case produced a confusing secondary error. The new regression tests enforce strict behavioral checks, ensuring that the scripted API receives requests and that failures propagate as Temporal ApplicationError instances with non-empty reasons. For chat interactions, the tests verify that message Updates fail explicitly rather than delivering error strings as normal replies.

Correcting the Error Handling Logic

The proposed fix, documented in PR #411, modifies the response handler to check the is_error flag before processing the answer. On failure, the handler extracts the reason from the result or errors list and raises an ApplicationError, ensuring that only successful results proceed to normal handling. This ordering is critical for structured outputs, where checking for a failed turn must precede diagnosing missing values to preserve the true cause of the failure. In chat scenarios, the fix ensures that failed message Updates leave the reference to the last good reply unchanged, preventing error strings from becoming the conversation's new successful answer. While the change makes failures visible to callers, it does not mandate specific retry policies, leaving authentication, rate limit, and connection errors to be handled by separate infrastructure logic.

Key Takeaways

  • Temporal Workflows cannot infer failure from string returns; explicit error checking is required.
  • The is_error flag must be validated before interpreting result content to avoid masking root causes.
  • Offline fixtures with deterministic HTTP errors enable reliable regression testing for API failures.
  • PR #411 remains open as of November 16, 2026, despite local test passes.

The Bottom Line

This incident is a harsh reminder that 'successful' workflow execution does not equal business success. If your agents return strings without checking failure flags, you are likely logging lies in your production dashboards.