Skip to content

A model stream that breaks part way says the connection dropped, with Carry on - #2896

Open
davidmckayv wants to merge 1 commit into
mainfrom
fix/run-died-slides
Open

davidmckayv wants to merge 1 commit into
mainfrom
fix/run-died-slides

Conversation

@davidmckayv

@davidmckayv davidmckayv commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Found on OpenBot Cloud (1.2.9, Desktop connected to Cloud). A Bot on GPT-6.1 Terra said "I'll make a short call deck…" and started a Google Slides call. About 44 seconds in, while it was still writing the deck into that call, OpenAI's stream broke: the model gateway logged the stream ended by the provider, and 4 ms later the engine's fetch threw TypeError: terminated, caused by read ECONNRESET. The Slides action never ran. The person read "The Bot stopped before it finished answering. Try again.", with no Carry on. That told them nothing about what happened.

The cause was a single upstream reset, the only one in about 1,260 Responses streams on Cloud that day. Providers drop streams like this now and then, and OpenAI's own Codex client retries them. What was ours is what the person read. OpenBot already has the right ending for this ("The connection to OpenAI dropped. Ask the Bot to carry on." with Carry on, and an unattended task tries again by itself). The engines just never said the connection had dropped:

  • LangGraph (TypeScript) engine, which new Bots and OpenBot Cloud run on: a connection that breaks after the answer began (undici's terminated, ECONNRESET, UND_ERR_SOCKET, "other side closed") now ends the run with Connection dropped (ECONNRESET) before <provider> finished answering., code OPENBOT_MODEL_REFUSED, category unknown. It used to end with the generic RUN_FAILED line. The category is not server_error on purpose: behind the sign-in proxy that category would decide, and the person would be told the provider is having problems. The engine now logs the error itself for a dropped connection, rather than "refused".
  • LangGraph (Python) engine: the same words and code. The OpenAI SDK raises APIConnectionError("Connection error.") around httpx's ReadError for a stream reset while it reads. The engine took that for a model it couldn't reach, and told the person to check the model's address, even though the model had already answered part way. A connection that broke while reading (ReadError, RemoteProtocolError, WriteError) is now a dropped connection, never "couldn't reach".
  • Any Bot in Python that passes on its own words (a connected AG-UI Bot, or a framework harness): the app now reads Python's words for a cut connection ("[Errno 54] Connection reset by peer", h11's "peer closed connection without sending complete message body …", "Server disconnected without sending a response.", the OpenAI SDK's "Connection error.") the way it already read Node's. The person sees "The Bot's connection dropped before it finished. What it saved is shown here." with Carry on, not the raw words. These are never the browser's own, so they never read as the backend stopping.

The Claude Agent SDK engine already said this in Claude Code's words ("API Error: Connection dropped (ECONNRESET)"), and connected Bots that pass on Node's fetch words already got the notice.

Where it runs

  • New state that outlives a request? None.
  • What happens on the second replica? Nothing different: each run's ending is decided by the engine that ran it.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No.

Boundary and audit

  • Every acting call still goes through the gateway: resolve, decide, audit, then act.
  • New refusals and new failures each write a row.
  • Nothing new is trusted from the client that the server can resolve itself.

API and database

  • This changes nothing under api/, no app's requests, no database change and no release-policy.json.

Changelog

Chat and Bots.

  • A Bot whose model connection drops part way says so, with Carry on. When a provider's stream broke mid-answer, a Bot on the LangGraph (TypeScript) engine ended with "The Bot stopped before it finished answering. Try again.". A Bot on the LangGraph (Python) engine said OpenBot couldn't reach the model. Both now say the connection to the model dropped and offer Carry on, and a routine or task nobody is watching tries again by itself. A Bot in Python that passes on its own words for a cut connection gets the same notice instead of the raw words.

Proof

Red before, green after. The new tests were run against main's source, then against this branch:

Test main this branch
TS engine, through the model gateway on /v1/responses (the exact Cloud path: a line, a GOOGLESLIDES_CREATE_SLIDES_MARKDOWN call with a 40-slide deck in its arguments, then a TCP reset), and the next run answers fails: no code, the generic line passes
TS engine, a reset part way through a call on Chat Completions, Anthropic Messages and Gemini 3 fail 3 pass
Python engine, the same reset on a real socket fails: OPENBOT_MODEL_UNREACHABLE ("couldn't reach the AI model") passes
App, Python's words for a cut connection (stopped-turn.test.ts) fails passes

The resets are real: the test provider writes the stream up to the call's arguments and then resets the TCP connection (resetAndDestroy, SO_LINGER 0), so the engine reads ECONNRESET through the real SDKs, as it did on Cloud. The test gateway now breaks its answer when the provider's stream breaks, as the real gateway does. With pipe alone, the engine waited forever.

Whole suites: TS engine 114 pass (3 live-only skipped), typecheck clean. Python engine 259 pass. The 2 that fail (test_chatgpt_token_provider_atomic_writer_*, file mounts) fail the same way on main on this Mac. App stopped-turn 11 pass.

End to end, Chrome (Chromium) and Safari (WebKit). This ran on a throwaway box with the real product: the server, the LangGraph (TypeScript) engine and the web app, each built from the OpenBot ref under test, with a local Intelligence. The model was reached through aimock. For one marked message, aimock streams a line and a GOOGLESLIDES_CREATE_SLIDES_MARKDOWN call in OpenAI's own Responses format, then destroys the socket in the middle of the call's arguments. Every other request goes to the real OpenAI. Steps: a new Bot, send the message, read the notice, reload, press Carry on.

  • Before (main): both browsers show Atai's screen exactly. They show the line, the step "Googleslides create slides markdown", then "The Bot stopped before it finished answering. Try again." with no Carry on. The run fails in both browsers.
  • After (this branch): both browsers show "The connection to your model provider dropped. Ask the Bot to carry on." with Carry on. ("your model provider" because aimock stands at a non-OpenAI address; on Cloud the server names OpenAI.) The same shows after a reload. Carry on sends "Please carry on where you stopped." and the Bot answers. "The Bot stopped" appears nowhere. The run passes in both browsers.
  • Nothing else on screen moved: the same notice component and layout, now with its Carry on button.
Chromium WebKit
Before (main)
After: the connection dropped
After: reloaded
After: Carry on

… Carry on

When a provider's stream broke after the answer began (a reset socket part way through a tool
call's arguments), the LangGraph (TypeScript) engine ended the run with "The Bot stopped before it
finished answering. Try again.", and the LangGraph (Python) engine said OpenBot couldn't reach the
model, which had already answered part way. Both now end the run with "Connection dropped
(ECONNRESET) before <provider> finished answering.", coded so the server reads it as a dropped
connection: the person reads that the connection to their model dropped, with Carry on, and an
unattended task tries again by itself.

A Bot in Python that passes on httpx's or the OpenAI SDK's own words for the same ("Connection reset
by peer", "peer closed connection without sending complete message body", "Connection error.") now
gets the same notice in the app, with Carry on, instead of the raw words.
@davidmckayv
davidmckayv marked this pull request as ready for review December 3, 2026 20:52

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant