fix(adapters): set AG-UI parentMessageId on tool-first tool calls#739
fix(adapters): set AG-UI parentMessageId on tool-first tool calls#739tombeckenham wants to merge 5 commits into
Conversation
Bind TOOL_CALL_START to the stream's stable assistant message id via AG-UI `parentMessageId` in every text adapter, so a tool call that streams before any text no longer forces the assistant message id to change mid-stream (which destabilises UIMessage.id and can remount the message subtree in useChat). Fixes #477. Extends #480 (Anthropic only) to: - @tanstack/openai-base (Responses + Chat Completions) - @tanstack/ai-openrouter (Responses + Chat Completions) - @tanstack/ai-gemini (text + experimental text-interactions) - @tanstack/ai-ollama Adds a tool-first regression per adapter asserting the TOOL_CALL_START parentMessageId equals the TEXT_MESSAGE_START messageId. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (18)
📝 WalkthroughWalkthroughThis PR adds a ChangesTool-first streaming parentMessageId fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
🚀 Changeset Version Preview10 package(s) bumped directly, 21 bumped as dependents. 🟥 Major bumps
🟨 Minor bumps
🟩 Patch bumps
|
|
View your CI Pipeline Execution ↗ for commit d24a601
☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-anthropic
@tanstack/ai-client
@tanstack/ai-code-mode
@tanstack/ai-code-mode-skills
@tanstack/ai-devtools-core
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-groq
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-mcp
@tanstack/ai-ollama
@tanstack/ai-openai
@tanstack/ai-openrouter
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-utils
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
commit: |
|
Superseded — folded these changes directly into #480 (shaked-frame/fix/anthropic-tool-parent-message-id) via maintainer edit. Same commit, no new PR needed. |
Summary
parentMessageIdonTOOL_CALL_STARTin every text adapter so tool-first streams keep a stable assistant message id — a tool call that streams before any text no longer forcesUIMessage.idto change mid-stream (which can remount the message subtree inuseChat).TOOL_CALL_START: OpenAI Responses + Chat Completions (@tanstack/openai-base), OpenRouter (both), Gemini (text + experimental text-interactions), and Ollama.TOOL_CALL_START.parentMessageId === TEXT_MESSAGE_START.messageId.The processor already consumes the field (
chunk.parentMessageId ?? activeAssistantId), so the message is created with the correct id immediately and the laterTEXT_MESSAGE_STARTmatches — no rename, no remount.fixes #477
Verification
pnpm --filter @tanstack/openai-base --filter @tanstack/ai-gemini --filter @tanstack/ai-ollama --filter @tanstack/ai-openrouter --filter @tanstack/ai-anthropic exec vitest run— 496 passed (incl. 6 new tool-first regressions)nx run-many --target=test:typesacross the 5 packages — passnx run-many --target=test:eslintacross the 5 packages — 0 errors🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests