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: CopilotChatToolCallsView produces React duplicate-key warning when connect() replays historic tool call events over pre-populated message state #3928
Use CopilotKit v2 with InMemoryAgentRunner and register at least one frontend tool via useFrontendTool
Send a message that triggers a tool call and let the run complete (the tool call should appear in the chat UI)
Reload the page — or otherwise cause connectAgent() to be called on an agent whose messages state already contains the completed assistant message with the tool call
Open the browser DevTools console
✅ Expected Behavior
No console warnings. Each tool call should appear exactly once in the chat.
❌ Actual Behavior
The browser console shows:
Warning: Encountered two children with the same key, `call_uUF5OZtugHE6tyoC9PPtpAs6`.
Keys should be unique so that components maintain their identity across updates.
Non-unique keys may cause children to be duplicated and/or omitted —
the behavior is unsupported and could change in a future version.
at CopilotChatToolCallsView
at MemoizedSlotWrapper
at CopilotChatAssistantMessage
Root cause: When connectAgent() is called, InMemoryAgentRunner.connect() replays compacted historic events (including TOOL_CALL_START for completed tool calls) via @ag-ui/client's defaultApplyEvents. However, at that point the agent's messages state already contains those tool calls from the prior run. Because defaultApplyEvents pushes to message.toolCalls unconditionally — with no duplicate guard — the same toolCallId ends up in the array twice:
message.toolCalls=[{id: "call_abc123", ... },// ← already in initial state{id: "call_abc123", ... },// ← pushed again by replayed TOOL_CALL_START]
CopilotChatToolCallsView then maps this array using toolCall.id as a React key, producing the duplicate-key warning.
The existing deduplicateMessages() in CopilotChatMessageView only deduplicates at the message level; it does not dedup entries within each message's toolCalls array.
Fix suggestion: In CopilotChatToolCallsView, deduplicate message.toolCalls by id before rendering:
Cross-linking #3644 — same root-cause family (tool-call event dedup). This issue is the within-toolCalls-array facet (duplicate toolCallId inside one message → React duplicate-key warning in CopilotChatToolCallsView); #3644 is the cross-message facet (duplicate assistant message id). The current deduplicateMessages mitigation only operates at the message level and doesn't dedup within toolCalls, so this is still open.
Consolidating into #3644 — same tool-call-dedup root cause. #3644 is the cross-message facet (a duplicate assistant message id is merged with toolCalls ?? existing.toolCalls instead of a union, dropping tool calls); this issue is the within-array facet (CopilotChatToolCallsView maps toolCalls with key={toolCall.id} and no dedup, so a replayed duplicate toolCallId triggers a React duplicate-key warning). A single fix — union the tool calls on merge in deduplicateMessages and dedup by id in CopilotChatToolCallsView — closes both. Let's track it on #3644.
Activity
fix(react-core): deduplicate tool calls in CopilotChatToolCallsView t…
BenTaylorDev commentedon Jul 15, 2026
Cross-linking #3644 — same root-cause family (tool-call event dedup). This issue is the within-
toolCalls-array facet (duplicatetoolCallIdinside one message → React duplicate-key warning inCopilotChatToolCallsView); #3644 is the cross-message facet (duplicate assistant message id). The currentdeduplicateMessagesmitigation only operates at the message level and doesn't dedup withintoolCalls, so this is still open.BenTaylorDev commentedon Jul 21, 2026
Consolidating into #3644 — same tool-call-dedup root cause. #3644 is the cross-message facet (a duplicate assistant message id is merged with
toolCalls ?? existing.toolCallsinstead of a union, dropping tool calls); this issue is the within-array facet (CopilotChatToolCallsViewmapstoolCallswithkey={toolCall.id}and no dedup, so a replayed duplicatetoolCallIdtriggers a React duplicate-key warning). A single fix — union the tool calls on merge indeduplicateMessagesand dedup by id inCopilotChatToolCallsView— closes both. Let's track it on #3644.fix(react-core): keep all tool calls when merging duplicate messages (#…