TanStack AI version
latest - 0.10.3
Framework/Library version
19.2.4
Describe the bug and the steps to reproduce it
When using useChat with fetchServerSentEvents and the Anthropic adapter, assistant message IDs can change during a single streamed response when tool calls arrive before text.
This makes UIMessage.id unstable for React list keys and can remount the message subtree mid-stream.
Setup
Client:
const { messages } = useChat({
connection: fetchServerSentEvents('/api/reports/ask'),
})
return messages.map((msg) => (
<ReportMessage key={msg.id} message={msg} />
))
Server:
const stream = chat({
adapter: anthropicText('claude-sonnet-4-6'),
messages,
tools: [myServerTool],
})
return toServerSentEventsResponse(stream)
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://stackblitz.com/~/github.com/shaked-frame/ts-ai-reproduction
Screenshots or Videos (Optional)
example logs during streaming -
assistant|id=msg-1776683523350-hhod09 |key=1776683523350 during stream
assistant|id=anthropic-1776683527840-o09nzv |key=1776683523350 after server confirms
Do you intend to try to help solve this bug with your own PR?
Yes, I think I know how to fix it and will discuss it in the comments of this issue
Terms & Code of Conduct
TanStack AI version
latest - 0.10.3
Framework/Library version
19.2.4
Describe the bug and the steps to reproduce it
When using useChat with fetchServerSentEvents and the Anthropic adapter, assistant message IDs can change during a single streamed response when tool calls arrive before text.
This makes UIMessage.id unstable for React list keys and can remount the message subtree mid-stream.
Setup
Client:
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://stackblitz.com/~/github.com/shaked-frame/ts-ai-reproduction
Screenshots or Videos (Optional)
example logs during streaming -
Do you intend to try to help solve this bug with your own PR?
Yes, I think I know how to fix it and will discuss it in the comments of this issue
Terms & Code of Conduct