Skip to content

fix(tanstack-ai): avoid duplicate tool call ids#424

Open
vaibhavshn wants to merge 3 commits intomainfrom
fix-tanstack-ai-tool-call-id
Open

fix(tanstack-ai): avoid duplicate tool call ids#424
vaibhavshn wants to merge 3 commits intomainfrom
fix-tanstack-ai-tool-call-id

Conversation

@vaibhavshn
Copy link
Collaborator

Previously, all tool call ids were chatcmplt, which made new tool call requests and responses get appended to previous parts. This fixes it so all tool calls have unique tool call ids, same as workers-ai-provider.

  • Change generateId to use 'chatcmpl' prefix and truncated UUID format
  • Generate unique IDs per tool call index instead of trusting backend IDs
  • Track tool call state across chunks to ensure stable IDs in streaming
  • Update test assertions to expect 'chatcmpl-' prefix instead of 'workers-ai-'

- Change generateId to use 'chatcmpl' prefix and truncated UUID format
- Generate unique IDs per tool call index instead of trusting backend IDs
- Track tool call state across chunks to ensure stable IDs in streaming
- Update test assertions to expect 'chatcmpl-' prefix instead of 'workers-ai-'
- Change default test script to run once, add test:watch for watch mode
- Create ToolCallDisplay component with collapsible UI for tool calls
- Show tool name, arguments, and results in formatted JSON
- Add expand/collapse button with rotation animation
- Match tool calls with their results using toolCallId
- Skip rendering standalone tool-result parts (already shown in tool-call)
- Style differently for user vs assistant messages
- Add formatJson helper to pretty-print JSON strings
@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

🦋 Changeset detected

Latest commit: 39a9405

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/tanstack-ai Patch

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 27, 2026

Open in StackBlitz

npx https://pkg.pr.new/cloudflare/ai/ai-gateway-provider@424
npx https://pkg.pr.new/cloudflare/ai/@cloudflare/tanstack-ai@424
npx https://pkg.pr.new/cloudflare/ai/workers-ai-provider@424

commit: 043582a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant