fix: preserve assistant reasoning when replaying Open Responses output in tool loops - #18515
Open
ai-sdk-factory[bot] wants to merge 3 commits into
Open
fix: preserve assistant reasoning when replaying Open Responses output in tool loops#18515ai-sdk-factory[bot] wants to merge 3 commits into
ai-sdk-factory[bot] wants to merge 3 commits into
Conversation
Co-authored-by: Astro-Han <255364436+Astro-Han@users.noreply.github.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
The published @ai-sdk/open-responses package lost assistant reasoning when its generated content was replayed in a tool loop, sending zero reasoning items after parsing one.
Root Cause
The assistant-content switch in convertToOpenResponsesInput handled only text and tool-call parts, so parsed reasoning parts fell through without serialization; the offline reproduction confirmed one reasoning part was read and zero were sent.
Summary
Assistant reasoning parts are now serialized as Open Responses reasoning items with reasoning_text content. The request type was tightened accordingly, and a patch changeset was added.
Testing
Added regression coverage asserting that assistant reasoning becomes a correctly shaped reasoning input item.
End-to-end Validation
pnpm -C packages/open-responses build;pnpm -C examples/ai-functions exec tsx src/reproduction/issue-18513-open-responses-reasoning-round-trip.ts— the offline round trip sent one reasoning item instead of zero and exited successfully.Related Issues
Fixes #18513
Closes #18514