Repository navigation
A Bot asks its model again by itself when the connection drops, and carries on - #2944
Merged
Merged
Conversation
…arries on On OpenBot Cloud a Bot 17 steps into a turn stopped when chatgpt.com reset its stream 0.6 s after answering 200. Nothing in OpenBot cut it, but nothing retried an answer that broke once it had begun, so the run ended and the person had to press Carry on. The LangGraph (TypeScript) engine now asks a failed step again itself, as Claude Code does: a dropped connection, a stream error part way, a 408, 409, 5xx or 529, or a passing 429, up to 10 times with backoff from 500 ms to 32 s, the provider's retry-after kept to. A quota, billing or invalid request is never retried. Words already said carry on in the same message, with Anthropic's documented "continue from where you left off" request, and a half-written call is taken out of the thread with a closing snapshot. While it waits the run sends AG-UI CUSTOM openbot.reconnecting and openbot.reconnected. The model clients' own retries are off, so retries have one owner. Once every try is used up the run ends as before, with Carry on.
davidmckayv
requested review from
MikeRyanDev,
dustywusty,
guidovizoso,
mxmzb,
samjulien and
tylerslaton
as code owners
December 4, 2026 16:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Bot no longer stops partway through its work when the connection to its model drops. The LangGraph (TypeScript) engine, the one new Bots run on, now asks the model again by itself, with backoff, and the turn carries on from where it was. The "connection dropped" notice with Carry on appears only once every try is used up.
What happened
An internal user's Bot on OpenBot Cloud (Dec 4, 10:38 UTC) was 17 steps into a turn, and had just said it would do more, when it stopped. Read from that run's events and the server and engine logs:
TypeError: terminated(read ECONNRESET), and the run ended with a RUN_ERROR.model-gateway-silent, which never appeared. The server's idle limit is off for the gateway routes. The engine's undici body and headers timeouts are 300 s. The load balancer and Envoy are not on the engine-to-gateway hop. AWS NAT drops TCP only after 350 s idle. No pod restarted or ran out of memory; the 1.2.11 roll was about 19 minutes later. The longest gap anywhere was 3.4 s.What the leaders do
sequence_numbercursor. https://developers.openai.com/api/docs/guides/background. That works only on OpenAI's own Responses API, not on a ChatGPT plan, Anthropic or Gemini, and it keeps response data even understore: falseand Zero Data Retention. So it isn't used here.This follows Claude Code's numbers and Anthropic's documented recovery, and applies them to every provider the engine speaks to.
What changed
agent-langgraph-ts/src/retry.ts(new). It decides which failures are passing ones:overloaded_error, OpenAI'sserver_error); a 408, 409 or 5xx, 529 included; a passing 429.x-should-retry: false; a plan's harness error (the harness retries itself).retry-after-ms,retry-after). One that asks for more than a minute is said to the person, not waited out.run.ts. A failed step is asked again here, in the one place:MESSAGES_SNAPSHOTholding only the calls the step finally made, since a snapshot is the only AG-UI way to take a call back out of the thread. Every other run still sends no snapshot.What the person sees while a step waits. The run sends plain AG-UI
CUSTOMevents, so any Bot can send them:openbot.reconnecting({ attempt, attempts, retryInMs }) while it waits;openbot.reconnectedonce the answer comes again.Nothing but CUSTOM events is sent during the wait. The web app draws them as "Reconnecting…" on the work line (Say "Reconnecting…" on the live line while a Bot retries its model #2942).
models.ts. The model client's own retries are off, so there's one owner of retries: ten tries, not ten times three. A run the server retries itself (openbotSendOnce) is still asked once.Unchanged once every try is used up. The run ends with the same RUN_ERROR as before, "Connection dropped (…) before … finished answering.", and the person reads the existing notice with Carry on.
Tests
test/reconnect.test.ts, through the real engine over HTTP, against the fake provider's real SSE wire formats. A cut is a TCP reset part way through the stream, the way the provider's broke on Cloud./v1/responsesbreaks after a line and part of a call. The run finishes with the call the next try made. The line is said once, and the thread the caller holds (applied with@ag-ui/client) has no half-written call.openbotSendOnce.model-route.test.ts's gateway test now covers this case.Red/green: with
run.tsandmodels.tsas they are onmain, 7 of the 12 new tests fail: every retried case, and the "asked ten times" one. With the change, all 12 pass, and the whole engine suite passes (126, with 3 live tests skipped).Changelog
Bots.