fix(ai): ignore a repeat TOOL_CALL_START for an already-tracked toolCallId - #1197
fix(ai): ignore a repeat TOOL_CALL_START for an already-tracked toolCallId#1197citizen204 wants to merge 4 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthrough
ChangesRepeated tool-call start handling
Model metadata formatting
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change ignores repeated tool-start events for an already-tracked call, preserving accumulated arguments and preventing duplicate tool execution. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the bug, fix, regression tests, changeset, linked issue, and test result. It does not follow the repository template because it omits the required checklist and release-impact sections. Full details: Linked Issues checkExplanation The implementation directly satisfies issue Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
2eecfc8 to
8f93f0b
Compare
|
View your CI Pipeline Execution ↗ for commit 4b73509
☁️ Nx Cloud last updated this comment at |
cf97e4a to
c861e75
Compare
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-claude-code
@tanstack/ai-client
@tanstack/ai-code-mode
@tanstack/ai-code-mode-snippets
@tanstack/ai-codex
@tanstack/ai-cohere
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@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-isolate-cloudflare
@tanstack/ai-isolate-daytona
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-isolate-quickjs-bun
@tanstack/ai-llmgateway
@tanstack/ai-lovable
@tanstack/ai-mcp
@tanstack/ai-memory
@tanstack/ai-mistral
@tanstack/ai-octane
@tanstack/ai-ollama
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-sandbox
@tanstack/ai-sandbox-cloudflare
@tanstack/ai-sandbox-daytona
@tanstack/ai-sandbox-docker
@tanstack/ai-sandbox-local-process
@tanstack/ai-sandbox-sprites
@tanstack/ai-sandbox-vercel
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-utils
@tanstack/ai-vercel-gateway
@tanstack/ai-vertex
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
@tanstack/svelte-ai-devtools
commit: |
c861e75 to
2bb5924
Compare
…allId AG-UI's TOOL_CALL_START carries no index, and a non-first-party or malformed producer can send a second START for a toolCallId that is already being tracked by ToolCallManager. Without a guard: - a repeat with the same index overwrites the slot, wiping any TOOL_CALL_ARGS already accumulated (arguments reset to '') - a repeat with a missing/different index inserts a duplicate map row, so getToolCalls() returns the id twice and the engine runs the tool twice Skip the repeat instead. First-party adapters emit START only once per call, so this only changes behavior for custom/malformed streams. Fixes TanStack#1187
2bb5924 to
b47be79
Compare
Summary
ToolCallManager.addToolCallStartEventkeyed its internal map byindex(event.index ?? map.size), but AG-UI'sTOOL_CALL_STARTcarries no index. A non-first-party or malformed producer sending a second START for atoolCallIdalready being tracked could either wipe accumulatedTOOL_CALL_ARGS(same index — overwrites the slot, resettingargumentsto'') or insert a duplicate row (missing/different index —getToolCalls()then returns the id twice and the engine runs the tool twice). First-party adapters emit START only once per call and are unaffected.Fixes #1187
Changes
packages/ai/src/activities/chat/tools/tool-calls.ts:addToolCallStartEventnow skips the event if a tool call with the sametoolCallIdis already tracked.packages/ai/tests/tool-call-manager.test.ts: two regression tests — a repeat START with the same explicit index (accumulated arguments must survive) and a repeat START with no index (must not duplicate the row)..changeset/tool-call-manager-repeat-start.md: patch changeset.Ran
vitest run tests/tool-call-manager.test.tsinpackages/ai— 31 passed (29 existing + 2 new).Summary by CodeRabbit
Bug Fixes
Tests