Uh oh!
There was an error while loading. Please reload this page.
fix(session): recover orphan reasoning stream parts - #41630
Open
bvolpato wants to merge 3 commits into
Open
Conversation
The AI SDK enqueues a non-fatal "reasoning part <id> not found" / "text part <id> not found" error part when a reasoning/text delta arrives with no preceding *-start block (common with OpenAI-compatible and Anthropic proxies). The adapter promoted every error part to a fatal Effect.fail, aborting the turn and spamming logs. Recognize these SDK-internal orphan stream-state errors and drop them instead of failing; genuine errors still fail.
Proxies that stream deltas without a preceding *-start caused the processor to drop the delta and any providerMetadata riding on it, including Anthropic thinking signatures. Repair the stream in the adapter by emitting the missing start before the delta.
Contributor
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Contributor
The following comment was made by an LLM, it may be inaccurate: Related PRs Found#39287 -
#26167 -
These are related PRs in the same stream recovery space, but #39287 is the direct predecessor that this PR builds upon. |
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 freeto 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.
Issue for this PR
Closes#36241
Type of change
What does this PR do?
AI SDK reports a missing reasoning/text start as an in-band
part ... not founderror, then keeps streaming. OpenCode promoted that bookkeeping error to a fatal turn failure.Emit a missing start before orphan deltas or end events, preserve provider metadata, and ignore only matching AI SDK bookkeeping errors. Real provider errors still fail.
Based on #39287 by DragonBaiMo, rebased onto current
dev, with coverage moved into current adapter suite. Existing PR no longer passes that suite after recent adapter changes.How did you verify your code works?
bun test test/session/llm.test.ts: 29 passbun typecheckfrompackages/opencodeScreenshots / recordings
Not applicable.
Checklist