Skip to content

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

Closed

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

Activity

  1. NathanColosimo commented on Jun 30, 2026

    @NathanColosimo
    Contributor

    Should be fixed as a part of the next versions, let us know if still any issues! fixed in #2699 - will be backported soon to 4.x #2703 @iNishant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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