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 3 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 (3)
🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthrough
ChangesRepeated tool-call start handling
Merge Risk: ⚪ Minimal · up to The change ignores duplicate tool-call start events while preserving accumulated arguments and preventing duplicate execution entries; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Description checkExplanation The description explains the bug, the fix, the affected files, regression tests, changeset, linked issue, and test result. It does not use the template's Checklist or Release Impact headings, but the required change details are otherwise complete. 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 dc73413
☁️ 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-compaction
@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-upstash-box
@tanstack/ai-sandbox-vercel
@tanstack/ai-skills
@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: |
2bb5924 to
b47be79
Compare
4de69a1 to
29aa341
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…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
29aa341 to
dc73413
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