This solution has been AI generated
Your interrupt UI renders, but the graph never resumes. This usually means the resolution isn’t being sent back to the exact interrupt event/thread, or the resolve callback is lost on re-render. Ensure you resolve the current interrupt event in the same thread, and that the agent is streaming events.
What to verify
- Resolve is called immediately with a string from the submit handler.
- Keep handler stable to avoid stale closures on re-render.
- The agent is running and streaming events; interrupts are only processed when events flow.
- Thread consistency: the same threadId used by
useAgentis the one the interrupt belongs to.
Minimal working pattern
// Stable submit handler and controlled input
function InterruptForm() {
const [response, setResponse] = useState("");
useLangGraphInterrupt({
render: ({ event, resolve }) => (
<form
onSubmit={(e) => {
e.preventDefault();
resolve(response); // send the value to resume the graph
}}
>
<p>{event.value}</p>
<input value={response} onChange={(e) => setResponse(e.target.value)} />
<button type="submit">Submit</button>
</form>
),
});
return null;
}
Ensure event streaming and thread alignment
const { agent, threadId } = useAgent({ agentId: "agent" });
// Subscribe so interrupts are delivered
useEffect(() => {
const unsub = agent.subscribe(() => {});
return unsub;
}, [agent]);
// Start/run the graph so events flow
// agent.run({...}) or your existing trigger that produced the interrupt
Alternative hook API (from codebase example)
const { resolveInterrupt } = useLangGraphInterrupt();
<form onSubmit={(e)=>{ e.preventDefault(); resolveInterrupt(response); }}>
...