fix(session): preserve reasoning across empty tool-call deltas - #47880
Open
yixiao5428 wants to merge 1 commit into
Open
fix(session): preserve reasoning across empty tool-call deltas#47880yixiao5428 wants to merge 1 commit into
yixiao5428 wants to merge 1 commit into
Conversation
Backport the nonempty tool-call guard from vercel/ai#20253 to the pinned @ai-sdk/openai-compatible@2.0.41 source, ESM and CJS targets. Preserve the existing structured-error patch and real text/tool boundaries without changing processor or adapter production code. Add 26 regression and boundary tests through the real SDK, stream adapter and session persistence, including error/interruption cleanup. Upstream: vercel/ai#20253 Refs: anomalyco#47875 Co-Authored-By: Claude <noreply@anthropic.com>
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.
Issue for this PR
Closes #47875
Type of change
What does this PR do?
Backports vercel/ai#20253, released in compatible
3.0.44, to OpenCode's pinned@ai-sdk/openai-compatible@2.0.41.The parser currently ends active reasoning for
tool_calls: [], splitting consecutive reasoning deltas into separate persisted parts. Requiring a nonempty array before entering the tool branch removes that false boundary while preserving real text/tool boundaries and normal stream completion.Related work and differences
This targets the empty-array case in #47875, not every symptom in #40865 or general reasoning/text coalescing.
How did you verify your code works?
Commands below use workspace-relative paths. Validation ran in a source tree matching this commit, installed with
bun install --frozen-lockfile:env -u ANTHROPIC_BASE_URL bun test --cwd packages/opencode --timeout 30000 test/session test/permission test/provider bun run --cwd packages/opencode typecheck bun run typecheck --forceThe test subprocess unsets an inherited custom Anthropic endpoint that interferes with the Gateway routing fixtures. No tests or user configuration were changed to accommodate it.
Screenshots / recordings
N/A — no UI code changes; regression coverage verifies stream events and persisted reasoning parts.
Checklist
🤖 Generated with Claude Code