Skip to content

DurableAgent.streamText kills the stream on tool input validation errors; core ai SDK recovers #1841

@iNishant

Description

@iNishant

Versions

  • @workflow/ai: 4.1.2
  • ai: 6.0.134

Summary

When an assistant tool call has a malformed input (bad JSON, or a value that fails the tool's inputSchema validation), DurableAgent.streamText throws out of executeTool, which propagates up through streamTextIterator and terminates the stream.

The core ai SDK handles the same failure differently: it converts the parse/validation failure into an invalid: true tool call, emits a tool-input-error UIMessage chunk, keeps the loop alive, and lets the model see the validator message on the next step so it can self-correct.

Expected behavior

Schema-shape failures should be recoverable — fed back to the model on the next step rather than killing the stream. Runtime zod validation throws are the normal feedback channel the model uses to fix an argument, so a single bad arg shouldn't end the turn.

This is also internally inconsistent: if the tool's execute function throws after parsing, the error is already converted to an error-text tool result and flows back to the model. Only the parse/validate path is fatal.

Relevant code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions