β»οΈ Reproduction Steps
- Run the standard Node-proxy setup: a
CopilotRuntime with an HttpAgent pointing at a remote AG-UI endpoint, served via copilotRuntimeNodeHttpEndpoint. Frontend uses CopilotChat.
- Start a chat and send a message that produces a streamed assistant response of a few seconds.
- While the assistant is still streaming text (i.e. between
TEXT_MESSAGE_START and TEXT_MESSAGE_END), press the Stop button.
- Observe the console error (below). The assistant message is left in a broken state and the chat becomes unreliable.
Minimal server setup that reproduces:
const { CopilotRuntime, EmptyAdapter, copilotRuntimeNodeHttpEndpoint } = require('@copilotkit/runtime');
const { HttpAgent } = require('@ag-ui/client');
const runtime = new CopilotRuntime({
agents: { my_agent: new HttpAgent({ url: 'http://localhost:8000/api' }) },
});
const handler = copilotRuntimeNodeHttpEndpoint({ runtime, serviceAdapter: new EmptyAdapter(), endpoint: '/copilotkit' });
β¦where http://localhost:8000/api is any AG-UI-compliant agent that streams a TEXT_MESSAGE_START β TEXT_MESSAGE_CONTENTβ¦ response and does not close the message before the run is aborted (e.g. pydantic-ai's AGUIAdapter β see pydantic/pydantic-ai#3108).
β
Expected Behavior
Pressing Stop should end the run cleanly: the open text message is closed and a single terminal event (RUN_FINISHED) is emitted. No console error. The chat remains usable for the next message.
Per the AG-UI spec invariant: at most one terminal event per run, and all sub-events (TEXT_MESSAGE_END, TOOL_CALL_END) must close before the terminal.
β Actual Behavior
The browser throws:
Agent execution failed: Cannot send event type 'TEXT_MESSAGE_END':
The run has already errored with 'RUN_ERROR'. No further events can be sent.
Screenshots
No response
π CopilotKit Version
@copilotkit/react-core 1.62.2
@copilotkit/react-ui 1.62.2
@copilotkit/runtime 1.62.2
π Logs (Optional)
Error message in the browser:
Agent execution failed: D: Cannot send event type 'TEXT_MESSAGE_END': The run has already errored with 'RUN_ERROR'. No further events can be sent.
Example data in response
...
data: {"type":"TEXT_MESSAGE_CONTENT","timestamp":1783057434585,"messageId":"225f30a2-c662-4d0d-a05e-789cb51e17cc","delta":" frames"}
data: {"type":"RUN_ERROR","message":"This operation was aborted","code":"abort","rawEvent":{}}
data: {"type":"TEXT_MESSAGE_END","messageId":"225f30a2-c662-4d0d-a05e-789cb51e17cc"}
β»οΈ Reproduction Steps
CopilotRuntimewith anHttpAgentpointing at a remote AG-UI endpoint, served viacopilotRuntimeNodeHttpEndpoint. Frontend usesCopilotChat.TEXT_MESSAGE_STARTandTEXT_MESSAGE_END), press the Stop button.Minimal server setup that reproduces:
β¦where
http://localhost:8000/apiis any AG-UI-compliant agent that streams aTEXT_MESSAGE_STARTβTEXT_MESSAGE_CONTENTβ¦ response and does not close the message before the run is aborted (e.g. pydantic-ai'sAGUIAdapterβ see pydantic/pydantic-ai#3108).β Expected Behavior
Pressing Stop should end the run cleanly: the open text message is closed and a single terminal event (
RUN_FINISHED) is emitted. No console error. The chat remains usable for the next message.Per the AG-UI spec invariant: at most one terminal event per run, and all sub-events (TEXT_MESSAGE_END, TOOL_CALL_END) must close before the terminal.
β Actual Behavior
The browser throws:
Screenshots
No response
π CopilotKit Version
π Logs (Optional)