Skip to content

DurableAgent surfaces fatal stream errors as [object Object] and does not clearly signal a terminal failure to stream consumers #1545

@craze3

Description

@craze3

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:

Environment

  • workflow: 4.2.0-beta.71
  • @workflow/ai: 4.1.0-beta.57
  • ai: 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]
Image

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

  1. 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
  2. Ensure fatal stream-processing errors are exposed to consumers as terminal failures, so reconnect/resume logic can stop immediately.

  3. Keep Preserve reasoning content in DurableAgent conversation history #1444 moving, since reasoning preservation appears to address one upstream trigger for this failure path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions