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
You're correct that no updates: [] (or equivalent subscription filter) is passed, which means the hook subscribes to all agent state updates. Every event the agent receives (messages streaming in, state changes, etc.) can trigger a re-render of whatever component hosts useInterrupt.
Additionally, the hook holds several pieces of its own state:
So the component re-renders both when agent state changes and when these internal states change.
Why Your Workaround Helps
Isolating useInterrupt into its own child component (<AddUseInterrupt />) is effective because:
Re-renders caused by useAgent's subscription are contained to that child
The parent component (ChatInterface2) and <CopilotChat> are not in the re-render subtree
React's component boundary prevents the render count from bubbling up
This is actually a solid pattern regardless of how this gets addressed internally.
Recommended Workaround (Until This Is Addressed)
Code example (tsx)
// Isolate useInterrupt into its own componentconstInterruptHandler=()=>{useInterrupt({render: ({ event, resolve })=>(<divclassName="p-3 border rounded"><p>{event.value.question}</p><divclassName="mt-2 flex gap-2"><buttononClick={()=>resolve({approved: true})}>Approve</button><buttononClick={()=>resolve({approved: false})}>Reject</button></div></div>),});returnnull;// renders nothing itself; UI goes into <CopilotChat> via renderInChat};exportconstChatInterface2=()=>{return(<><InterruptHandler/><CopilotChatagentId={AGENT_NAME}/></>);};
Note:useInterrupt with default renderInChat: true publishes its element into <CopilotChat> via copilotkit.setInterruptElement(element) (visible in the source at line 489), so returning null from InterruptHandler is correct — the UI still appears inside the chat.
What I'd Flag for the Team
The useAgent call inside useInterrupt without subscription filtering is the likely source of the extra renders — engineering will need to verify whether a subscription filter is the right fix or whether the agent context needs to be consumed differently here
I cannot confirm this as a bug or prescribe the internal fix — that's for the maintainers to determine
I've noted your reproduction steps and version (1.70.0) are clear and actionable. The team should have everything they need to investigate.
Was this helpful? Let me know if you want help structuring the InterruptHandler pattern for a more complex use case (e.g., multiple interrupt types or renderInChat: false).
🤖 Generated by CopilotKit AI Support · Documentation
Activity
copilotkit-outpost-bot commentedon Sep 7, 2026
Re-render Report:
useInterruptTriggering Excessive Re-rendersThanks for the detailed reproduction — this is a well-structured report with a clear workaround already identified.
What the Code Shows
Looking at
packages/react-core/src/v2/hooks/use-interrupt.tsx,useInterruptinternally calls:Code example (ts)
You're correct that no
updates: [](or equivalent subscription filter) is passed, which means the hook subscribes to all agent state updates. Every event the agent receives (messages streaming in, state changes, etc.) can trigger a re-render of whatever component hostsuseInterrupt.Additionally, the hook holds several pieces of its own state:
So the component re-renders both when agent state changes and when these internal states change.
Why Your Workaround Helps
Isolating
useInterruptinto its own child component (<AddUseInterrupt />) is effective because:useAgent's subscription are contained to that childChatInterface2) and<CopilotChat>are not in the re-render subtreeThis is actually a solid pattern regardless of how this gets addressed internally.
Recommended Workaround (Until This Is Addressed)
Code example (tsx)
What I'd Flag for the Team
useAgentcall insideuseInterruptwithout subscription filtering is the likely source of the extra renders — engineering will need to verify whether a subscription filter is the right fix or whether the agent context needs to be consumed differently hereI've noted your reproduction steps and version (
1.70.0) are clear and actionable. The team should have everything they need to investigate.Was this helpful? Let me know if you want help structuring the
InterruptHandlerpattern for a more complex use case (e.g., multiple interrupt types orrenderInChat: false).🤖 Generated by CopilotKit AI Support · Documentation
Was this helpful? React with 👍 or 👎
fix #6934: stop useInterrupt re-renders on agent updates
fix(react-core): stop useInterrupt re-renders on agent updates (#6969)