-
Notifications
You must be signed in to change notification settings - Fork 221
DurableAgent surfaces fatal stream errors as [object Object] and does not clearly signal a terminal failure to stream consumers #1545
Description
Summary
When DurableAgent hits a fatal mid-turn error, stream consumers can receive an opaque "[object Object]" error instead of a real message.
In the same failure path, the run/stream state can remain ambiguous enough that consumers may still attempt reconnect/resume logic even though the turn is effectively dead.
This appears to be a separate bug from the underlying reasoning/tool-loop issue in:
- DurableAgent should preserve reasoning content in conversation history across tool loop steps #1393
- Preserve reasoning content in DurableAgent conversation history #1444
- Bug: DurableAgent + OpenAI Responses API fails on tool calls due to missing required
reasoningitem #880 - fix(ai): strip openai itemID from tool call metadata #889
Environment
workflow:4.2.0-beta.71@workflow/ai:4.1.0-beta.57ai:6.0.116
Problem
In a fatal DurableAgent stream failure, a structured error object can be collapsed to:
[object Object]
I also saw the library log:
Error processing UI message chunks: Error: [object Object]
This makes the real failure cause invisible to downstream consumers.
Separately, after this kind of fatal error, the failure is not always clearly terminal from the perspective of a stream consumer. A consumer may still treat the run as reconnectable/resumable even though the turn has already failed.
Expected behavior
- Fatal stream errors should surface a useful message, not
"[object Object]". - Non-recoverable stream failures should be clearly terminal so consumers do not keep trying to resume a dead turn.
Suggested fix
-
Replace
String(error)for unknown errors with a safer formatter:- prefer
error.message - otherwise serialize structured objects with
JSON.stringify(...)when possible - fall back to a generic message only as a last resort
- prefer
-
Ensure fatal stream-processing errors are exposed to consumers as terminal failures, so reconnect/resume logic can stop immediately.
-
Keep Preserve reasoning content in DurableAgent conversation history #1444 moving, since reasoning preservation appears to address one upstream trigger for this failure path.