Skip to content
Source
Sign inSign up
TanStack/ai

fix(ai): ignore TOOL_CALL_ARGS after a tool call ended #2274

Mergedcanblmz1(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/2274/headmerged by AlemTuzlak View on GitHub

canblmz1(GitHub profile, opens in a new tab)commented

🎯 Changes

After a tool call's TOOL_CALL_END, core still accepted TOOL_CALL_ARGS for the same call:

  • ToolCallManager.addToolCallArgsEvent appended the late delta (or replaced the arguments with args), so the server tool ran with different arguments or failed JSON.parse and never ran.
  • StreamProcessor.handleToolCallArgsEvent appended it to the UI part's finalized arguments, and could move a part that had already reached complete / error back to input-complete / input-streaming.

Both now ignore TOOL_CALL_ARGS for a call that has ended (manager: after TOOL_CALL_END; processor: when the call is input-complete or its part is terminal). Arguments before END are handled as before. This protects every adapter and custom stream; #2264 and #2273 fix two adapters that emitted such events.

  • Unit: new cases in tool-call-manager.test.ts (late delta, late full args) and stream-processor.test.ts (input-complete, complete, error). All 5 fail on main; tool-call-manager + stream-processor: 320 passed.
  • E2E: late-tool-args-wire streams a getWeather call, then a late } delta after TOOL_CALL_END, from a server route through ChatClient over HTTP. On main the part ends with arguments: {"city":"Paris"}} and Failed to parse tool arguments as JSON; with this change it's complete with Sunny in Paris.
  • Docs: one sentence in docs/chat/stream-events.md: TOOL_CALL_END finalizes the arguments, and later TOOL_CALL_ARGS for the same call are ignored.

Verified locally: @tanstack/ai test:lib and test:types, oxlint, oxfmt --check, and the new Playwright spec against the dev server. I did not run the full pnpm run test:pr.

The fix and tests were written with AI assistance (Codex, Claude); I reviewed and verified them as above.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with 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 full test:pr.)
  • I fully understand the code in this pull request, including any code generated with AI assistance.
  • Docs: I updated docs/ for this change, or this change is not user-facing.
  • Changeset: I added a changeset (pnpm changeset), or this PR does not change a published package.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes
    • Tool calls now retain the arguments finalized when the call ends. Late argument updates no longer change completed or failed calls, helping ensure tools execute once with the intended input and chat clients preserve the finished call.
  • Documentation
    • Clarified that argument updates received after a tool call ends are ignored.
    1. Pushed0027e8d

    2. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 0027e8de998fbda2e0ddb17229e8a74260aad092

      CommandStatusDurationResult
      nx run-many --targets=test:coverage --projects=...✅ Succeeded4sView ↗
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded12m 15sView ↗
      nx run-many --targets=build --exclude=examples/...✅ Succeeded2m 42sView ↗

      💡 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 2026-11-30 09:49:31 UTC

    3. Open in StackBlitz

      @tanstack/ai

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@2274

      @tanstack/ai-acp

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-acp@2274

      @tanstack/ai-angular

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-angular@2274

      @tanstack/ai-anthropic

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@2274

      @tanstack/ai-bedrock

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-bedrock@2274

      @tanstack/ai-byteplus

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-byteplus@2274

      @tanstack/ai-cartesia

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cartesia@2274

      @tanstack/ai-claude-code

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-claude-code@2274

      @tanstack/ai-client

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@2274

      @tanstack/ai-cloudflare

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cloudflare@2274

      @tanstack/ai-code-mode

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode@2274

      @tanstack/ai-code-mode-snippets

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode-snippets@2274

      @tanstack/ai-codex

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-codex@2274

      @tanstack/ai-cohere

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cohere@2274

      @tanstack/ai-compaction

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-compaction@2274

      @tanstack/ai-computer-local

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-computer-local@2274

      @tanstack/ai-computer-playwright

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-computer-playwright@2274

      @tanstack/ai-computer-sandbox

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-computer-sandbox@2274

      @tanstack/ai-computer-use

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-computer-use@2274

      @tanstack/ai-devtools-core

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@2274

      @tanstack/ai-durable-stream

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-durable-stream@2274

      @tanstack/ai-effect

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-effect@2274

      @tanstack/ai-elevenlabs

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-elevenlabs@2274

      @tanstack/ai-event-client

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-event-client@2274

      @tanstack/ai-fal

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-fal@2274

      @tanstack/ai-gemini

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@2274

      @tanstack/ai-grok

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@2274

      @tanstack/ai-grok-build

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok-build@2274

      @tanstack/ai-groq

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-groq@2274

      @tanstack/ai-harness

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness@2274

      @tanstack/ai-harness-cli

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness-cli@2274

      @tanstack/ai-isolate-cloudflare

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-cloudflare@2274

      @tanstack/ai-isolate-daytona

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-daytona@2274

      @tanstack/ai-isolate-e2b

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-e2b@2274

      @tanstack/ai-isolate-node

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-node@2274

      @tanstack/ai-isolate-quickjs

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs@2274

      @tanstack/ai-isolate-quickjs-bun

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs-bun@2274

      @tanstack/ai-llmgateway

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-llmgateway@2274

      @tanstack/ai-lovable

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-lovable@2274

      @tanstack/ai-mcp

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp@2274

      @tanstack/ai-mcp-sandbox

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp-sandbox@2274

      @tanstack/ai-memory

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-memory@2274

      @tanstack/ai-meshy

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-meshy@2274

      @tanstack/ai-mistral

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mistral@2274

      @tanstack/ai-muse

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-muse@2274

      @tanstack/ai-neon

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-neon@2274

      @tanstack/ai-octane

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-octane@2274

      @tanstack/ai-ollama

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@2274

      @tanstack/ai-ollaya

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollaya@2274

      @tanstack/ai-openai

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@2274

      @tanstack/ai-opencode

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-opencode@2274

      @tanstack/ai-openrouter

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openrouter@2274

      @tanstack/ai-optimize

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-optimize@2274

      @tanstack/ai-perplexity

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-perplexity@2274

      @tanstack/ai-persistence

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-persistence@2274

      @tanstack/ai-preact

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@2274

      @tanstack/ai-react

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@2274

      @tanstack/ai-reactor

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-reactor@2274

      @tanstack/ai-remix

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-remix@2274

      @tanstack/ai-sandbox

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox@2274

      @tanstack/ai-sandbox-blaxel

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-blaxel@2274

      @tanstack/ai-sandbox-boxd

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-boxd@2274

      @tanstack/ai-sandbox-cloudflare

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-cloudflare@2274

      @tanstack/ai-sandbox-daytona

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-daytona@2274

      @tanstack/ai-sandbox-docker

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-docker@2274

      @tanstack/ai-sandbox-e2b

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-e2b@2274

      @tanstack/ai-sandbox-local-process

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-local-process@2274

      @tanstack/ai-sandbox-railway

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-railway@2274

      @tanstack/ai-sandbox-sprites

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-sprites@2274

      @tanstack/ai-sandbox-upstash-box

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-upstash-box@2274

      @tanstack/ai-sandbox-vercel

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-vercel@2274

      @tanstack/ai-skills

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-skills@2274

      @tanstack/ai-solid

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@2274

      @tanstack/ai-svelte

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@2274

      @tanstack/ai-tripo

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-tripo@2274

      @tanstack/ai-typesafe

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-typesafe@2274

      @tanstack/ai-uthana

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-uthana@2274

      @tanstack/ai-utils

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-utils@2274

      @tanstack/ai-vercel-compat

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vercel-compat@2274

      @tanstack/ai-vercel-gateway

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vercel-gateway@2274

      @tanstack/ai-vertex

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vertex@2274

      @tanstack/ai-vue

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@2274

      @tanstack/ai-worldlabs

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-worldlabs@2274

      @tanstack/openai-base

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/openai-base@2274

      @tanstack/preact-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/preact-ai-devtools@2274

      @tanstack/react-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@2274

      @tanstack/solid-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@2274

      @tanstack/svelte-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/svelte-ai-devtools@2274

      commit: 0027e8d

    4. AlemTuzlak approved these changes

    5. AlemTuzlak merged this53cbb4c

    6. AlemTuzlak closed this

Sign in to join this conversation.