You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
🐛 Bug: Duplicate assistant message IDs when multiple tool calls are interleaved with tool results #3644
When using CopilotKit with an AG-UI event stream that contains multiple TOOL_CALL_START events for the same assistant message, interleaved with TOOL_CALL_RESULT events, the
frontend can end up with duplicate assistant message IDs in messages[].
In development mode, this triggers:
CopilotChatMessageView: Deduplicated 1 message(s) with duplicate IDs.
This seems to happen with a sequence like this:
An assistant text message is created with messageId = msg_x
So once duplicate IDs appear, one of the messages is dropped from rendering. In my case, the later duplicate assistant message had empty content and only the last tool call, so deduplication effectively hid the earlier assistant content/tool calls.
The issue appears to come from the event-application logic for TOOL_CALL_START.
The current logic seems to only attach the tool call to the parent assistant message if the last message in the array has `id === parentMessageId`.
That works until a TOOL_CALL_RESULT is appended as a separate role: "tool" message. After that, the last message is no longer the parent assistant message, so a later TOOL_CALL_START for the same parent creates a new assistant message with the same ID instead of merging into the existing one.
In other words, the logic is too dependent on "last message" position and does not search for the existing assistant message by parentMessageId.
Cross-linking #3928 — same root-cause family. Both stem from missing idempotency/dedup when tool-call events are applied/rendered (upstream @ag-ui/clientdefaultApplyEvents has no duplicate guard). This issue is the cross-message facet (a second assistant message with the same id); #3928 is the within-toolCalls-array facet (same toolCallId twice → React duplicate-key warning). A proper fix likely needs both: union tool calls when merging duplicate-id messages, and dedup toolCalls in CopilotChatToolCallsView.
This issue is already claimed externally. Please don’t start new work on it. If you need this fixed immediately, please reach out to us in our Discord or via [email protected].
Activity
fix(react-core): merge toolCalls by id when deduplicating duplicate a…
BenTaylorDev commentedon Jul 15, 2026
Cross-linking #3928 — same root-cause family. Both stem from missing idempotency/dedup when tool-call events are applied/rendered (upstream
@ag-ui/clientdefaultApplyEventshas no duplicate guard). This issue is the cross-message facet (a second assistant message with the same id); #3928 is the within-toolCalls-array facet (sametoolCallIdtwice → React duplicate-key warning). A proper fix likely needs both: union tool calls when merging duplicate-id messages, and deduptoolCallsinCopilotChatToolCallsView.linear commentedon Jul 21, 2026
OSS-528
tylerslaton commentedon Sep 30, 2026
This issue is already claimed externally. Please don’t start new work on it. If you need this fixed immediately, please reach out to us in our Discord or via [email protected].
miah7 commentedon Nov 12, 2026
Hi Im a CS146S student commenting to work on issue!
fix(react-core): keep all tool calls when merging duplicate messages (#…
fix(react-core): keep all tool calls when merging duplicate messages