This solution has been AI generated
You’re seeing RUN_ERROR (code: INCOMPLETE_STREAM) because the chat "Send" starts a new run while the LangGraph run is paused at an interrupt. To support typing a reply, intercept the chat submission and resolve the active interrupt with a "response" action instead of starting a new run.
Why this happens
When an interrupt is active, LangGraph waits for a resume. Sending a chat message triggers a new run, so the prior run never emits a terminal event, resulting in INCOMPLETE_STREAM.
Client-side fix: map chat input to the interrupt "response"
Use useLangGraphInterrupt to capture the current resolve and redirect CopilotChat's onSubmitMessage to it.
import React from "react";
import { useLangGraphInterrupt } from "@copilotkit/react-core";
import { CopilotChat } from "@copilotkit/react-ui";
export function MyChat() {
const resolveRef = React.useRef<((v: any) => void) | null>(null);
useLangGraphInterrupt({
render: ({ event, resolve }) => {
resolveRef.current = resolve;
return (
<div>
<p>{event.value?.content}</p>
<button onClick={() => resolve({ type: "accept" })}>Accept</button>
</div>
);
},
onCleanup: () => { resolveRef.current = null; }
});
return (
<CopilotChat
onSubmitMessage={async (message) => {
if (resolveRef.current) {
resolveRef.current({ type: "response", args: message });
return; // prevent starting a new run while interrupted
}
}}
/>
);
}
Agent-side handling (LangGraph)
Ensure your node expects the structured response and processes args.