You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@ai-sdk/open-responses: truncated stream emits reasoning-end with a hardcoded id, and unknown incomplete reasons are reported as tool-calls #18872
Two defects in the streaming path, both in @ai-sdk/open-responses@2.0.27. They are filed together because both surface on the same trace: a response that ends early while reasoning is open.
1. reasoning-end id does not match reasoning-start
With a real id such as rs_…, AI SDK core then injects error: reasoning part reasoning-0 not found. A truncated-but-otherwise-usable response is delivered to the caller as a stream error rather than a normal length finish. chunk.item.id is not in scope at flush time, so the fix is to remember the active reasoning id when reasoning-start is emitted and reuse it here.
2. An unrecognized incomplete_details.reason becomes tool-calls
max_output_tokens and content_filter are handled correctly. Any other reason an OpenAI-compatible server reports falls to default, and when tool calls are present the truncation is reported as tool-calls — indistinguishable from a healthy tool round. An agent loop reads that as "the model wants to call a tool", continues, and never learns the response was cut short. The real reason survives on finishReason.raw, but unified is what control flow reads.
other for an unknown reason would be conservative and correct; hasToolCalls should not upgrade an unknown terminal state to a successful one.
This is a concrete report of two incorrect behaviors in the existing streaming implementation: mismatched reasoning IDs produce an unexpected stream error, and unknown incomplete reasons receive a misleading finish classification.
Evidence
The flush path emits reasoning-end with hardcoded id reasoning-0, which can mismatch the actual reasoning-start id and trigger reasoning part reasoning-0 not found.
Unknown incomplete_details.reason values are mapped to tool-calls when tool calls exist, causing a truncated response to be treated as a healthy tool-call round.
The report identifies both failures in the current streaming behavior of @ai-sdk/open-responses@2.0.27 and provides relevant implementation paths.
examples/ai-functions/src/reproduction/open-responses-truncated-reasoning.ts reproduces both defects against the checked-out @ai-sdk/open-responses@2.0.27 implementation.
With packages/open-responses/src/responses/__fixtures__/issue-18872-truncated-reasoning.chunks.txt, truncation while reasoning ID rs_actual_reasoning_id is open produces reasoning part reasoning-0 not found; the expected outcome is an error-free stream with finish reason length.
With packages/open-responses/src/responses/__fixtures__/issue-18872-unknown-incomplete-reason.chunks.txt, unknown reason server_timeout with a tool call is reported as tool-calls; the expected conservative unified reason is other while preserving the raw reason.
Regression assertions added to packages/open-responses/src/responses/open-responses-language-model.test.ts fail on the hardcoded reasoning-end ID and incorrect unknown-reason mapping.
The stream flush path retained only a reasoning-active boolean and hardcoded reasoning-0 instead of retaining the active item ID. Separately, the finish-reason mapper allowed hasToolCalls to override unknown terminal reasons. The recorded reproduction confirmed both outcomes.
Summary
The stream now retains and reuses the active reasoning ID during flush, while unknown incomplete reasons map conservatively to other. Added a patch changeset for @ai-sdk/open-responses.
Testing
Added stream regressions for truncated reasoning IDs and unknown incomplete reasons with tool calls, and updated finish-reason mapping coverage.
Activity
ai-sdk-factory commentedon Aug 13, 2026
Identify issue type
Identified as Bug
Confidence: High
Rationale
This is a concrete report of two incorrect behaviors in the existing streaming implementation: mismatched reasoning IDs produce an unexpected stream error, and unknown incomplete reasons receive a misleading finish classification.
Evidence
reasoning-endwith hardcoded idreasoning-0, which can mismatch the actualreasoning-startid and triggerreasoning part reasoning-0 not found.incomplete_details.reasonvalues are mapped totool-callswhen tool calls exist, causing a truncated response to be treated as a healthy tool-call round.@ai-sdk/open-responses@2.0.27and provides relevant implementation paths.ai-sdk-factory commentedon Aug 13, 2026
Bug Reproduction - AI SDK 7
Bug was reproduced.
Branch:
mainPR: successful reproduction pull request
Details
examples/ai-functions/src/reproduction/open-responses-truncated-reasoning.tsreproduces both defects against the checked-out@ai-sdk/open-responses@2.0.27implementation.packages/open-responses/src/responses/__fixtures__/issue-18872-truncated-reasoning.chunks.txt, truncation while reasoning IDrs_actual_reasoning_idis open producesreasoning part reasoning-0 not found; the expected outcome is an error-free stream with finish reasonlength.packages/open-responses/src/responses/__fixtures__/issue-18872-unknown-incomplete-reason.chunks.txt, unknown reasonserver_timeoutwith a tool call is reported astool-calls; the expected conservative unified reason isotherwhile preserving the raw reason.packages/open-responses/src/responses/open-responses-language-model.test.tsfail on the hardcoded reasoning-end ID and incorrect unknown-reason mapping.Relevant Documentation
fix #18872
ai-sdk-factory commentedon Aug 13, 2026
Bugfix - AI SDK 7
Created bugfix and opened PR: #18881
Root Cause
The stream flush path retained only a reasoning-active boolean and hardcoded reasoning-0 instead of retaining the active item ID. Separately, the finish-reason mapper allowed hasToolCalls to override unknown terminal reasons. The recorded reproduction confirmed both outcomes.
Summary
The stream now retains and reuses the active reasoning ID during flush, while unknown incomplete reasons map conservatively to other. Added a patch changeset for @ai-sdk/open-responses.
Testing
Added stream regressions for truncated reasoning IDs and unknown incomplete reasons with tool calls, and updated finish-reason mapping coverage.
n1ckoates commentedon Aug 13, 2026
github-actions commentedon Aug 14, 2026
🚀 Published in:
ai@ai-sdk/amazon-bedrock@ai-sdk/angular@ai-sdk/anthropic@ai-sdk/anthropic-aws@ai-sdk/code-mode@ai-sdk/google-vertex@ai-sdk/harness@ai-sdk/harness-acp@ai-sdk/harness-claude-code@ai-sdk/harness-cline@ai-sdk/harness-codex@ai-sdk/harness-deepagents@ai-sdk/harness-grok-build@ai-sdk/harness-opencode@ai-sdk/harness-pi@ai-sdk/langchain@ai-sdk/llamaindex@ai-sdk/mcp@ai-sdk/minimax@ai-sdk/open-responses@ai-sdk/otel@ai-sdk/policy-opa@ai-sdk/react@ai-sdk/rsc@ai-sdk/sandbox-just-bash@ai-sdk/sandbox-vercel@ai-sdk/svelte@ai-sdk/tui@ai-sdk/vue@ai-sdk/workflow@ai-sdk/workflow-harness