Repository navigation
fix(ai): ignore TOOL_CALL_ARGS after a tool call ended - #2274
Conversation
ToolCallManager appended a late TOOL_CALL_ARGS delta (or replaced the arguments) after TOOL_CALL_END, so the server tool failed to parse its finalized arguments or ran with different ones; StreamProcessor corrupted the UI arguments and could move a finished part back to input-complete. Ignore ARGS for a call that has ended in both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 0027e8d The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Thanks for the PR, @canblmz1! 🙌 @AlemTuzlak will take a look. Automated pre-review checks
Automated triage — a human review follows. |
|
View your CI Pipeline Execution ↗ for commit 0027e8d
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-cartesia
@tanstack/ai-claude-code
@tanstack/ai-client
@tanstack/ai-cloudflare
@tanstack/ai-code-mode
@tanstack/ai-code-mode-snippets
@tanstack/ai-codex
@tanstack/ai-cohere
@tanstack/ai-compaction
@tanstack/ai-computer-local
@tanstack/ai-computer-playwright
@tanstack/ai-computer-sandbox
@tanstack/ai-computer-use
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@tanstack/ai-effect
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-grok-build
@tanstack/ai-groq
@tanstack/ai-harness
@tanstack/ai-harness-cli
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-daytona
@tanstack/ai-isolate-e2b
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-isolate-quickjs-bun
@tanstack/ai-llmgateway
@tanstack/ai-lovable
@tanstack/ai-mcp
@tanstack/ai-mcp-sandbox
@tanstack/ai-memory
@tanstack/ai-meshy
@tanstack/ai-mistral
@tanstack/ai-muse
@tanstack/ai-neon
@tanstack/ai-octane
@tanstack/ai-ollama
@tanstack/ai-ollaya
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-optimize
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-reactor
@tanstack/ai-remix
@tanstack/ai-sandbox
@tanstack/ai-sandbox-blaxel
@tanstack/ai-sandbox-boxd
@tanstack/ai-sandbox-cloudflare
@tanstack/ai-sandbox-daytona
@tanstack/ai-sandbox-docker
@tanstack/ai-sandbox-e2b
@tanstack/ai-sandbox-local-process
@tanstack/ai-sandbox-railway
@tanstack/ai-sandbox-sprites
@tanstack/ai-sandbox-upstash-box
@tanstack/ai-sandbox-vercel
@tanstack/ai-skills
@tanstack/ai-solid
@tanstack/ai-svelte
@tanstack/ai-tripo
@tanstack/ai-typesafe
@tanstack/ai-uthana
@tanstack/ai-utils
@tanstack/ai-vercel-compat
@tanstack/ai-vercel-gateway
@tanstack/ai-vertex
@tanstack/ai-vue
@tanstack/ai-worldlabs
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
@tanstack/svelte-ai-devtools
commit: |
🎯 Changes
After a tool call's
TOOL_CALL_END, core still acceptedTOOL_CALL_ARGSfor the same call:ToolCallManager.addToolCallArgsEventappended the latedelta(or replaced the arguments withargs), so the server tool ran with different arguments or failedJSON.parseand never ran.StreamProcessor.handleToolCallArgsEventappended it to the UI part's finalized arguments, and could move a part that had already reachedcomplete/errorback toinput-complete/input-streaming.Both now ignore
TOOL_CALL_ARGSfor a call that has ended (manager: afterTOOL_CALL_END; processor: when the call isinput-completeor its part is terminal). Arguments beforeENDare handled as before. This protects every adapter and custom stream; #2264 and #2273 fix two adapters that emitted such events.tool-call-manager.test.ts(latedelta, late fullargs) andstream-processor.test.ts(input-complete,complete,error). All 5 fail onmain;tool-call-manager+stream-processor: 320 passed.late-tool-args-wirestreams agetWeathercall, then a late}delta afterTOOL_CALL_END, from a server route throughChatClientover HTTP. Onmainthe part ends witharguments: {"city":"Paris"}}andFailed to parse tool arguments as JSON; with this change it'scompletewithSunny in Paris.docs/chat/stream-events.md:TOOL_CALL_ENDfinalizes the arguments, and laterTOOL_CALL_ARGSfor the same call are ignored.Verified locally:
@tanstack/aitest:libandtest:types,oxlint,oxfmt --check, and the new Playwright spec against the dev server. I did not run the fullpnpm run test:pr.The fix and tests were written with AI assistance (Codex, Claude); I reviewed and verified them as above.
✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request. (Ran the affected package and E2E checks listed above, not the fulltest:pr.)docs/for this change, or this change is not user-facing.pnpm changeset), or this PR does not change a published package.🚀 Release Impact
Summary by CodeRabbit