Skip to content

Say "couldn't reach its backend" only when nothing answered the run - #2891

Open
davidmckayv wants to merge 5 commits into
mainfrom
fix/run-refusal-reason
Open

davidmckayv wants to merge 5 commits into
mainfrom
fix/run-refusal-reason

Conversation

@davidmckayv

Copy link
Copy Markdown
Contributor

What this changes

A first message the backend refused was told to the person as "OpenBot couldn't reach its backend, so your message wasn't sent. Try again, or quit and reopen OpenBot." That sentence is false when the backend answered, and quitting and reopening can't help.

Found on OpenBot Cloud 1.2.9 with OpenBot Desktop 1.2.0-rc.5 connected to it. A new conversation with a public Bot the runtime couldn't build: each of three runs was answered 404 with the runtime's own body, {"error":"Agent not found","message":"Agent '…' does not exist"}, while the API still listed the Bot and read it back. CopilotKit's Intelligence agent throws every failed run request as REST run request failed: <body>, status and headers gone, and stopped-turn.ts read every such failure as the backend being out of reach.

Now the body decides (app/src/lib/copilot/stopped-turn.ts):

  • A JSON body is the backend answering.
    • An OpenBot problem with a sentence for the person (the run gate's 403s and 409s) is shown in its own words, as before.
    • "Agent not found" for a Bot the server still reads back: "This Bot can't run because its setup isn't finished, so your message wasn't sent. Its owner or an admin can finish it in Setup." When the Bot is gone it still says the Bot isn't shared any more.
    • Anything else (a raw { "error": … }, a server fault): "OpenBot's backend couldn't start this turn, so your message wasn't sent. Try again, or ask an admin if it keeps happening." Joining a conversation says "couldn't open this conversation".
  • Only no answer is "couldn't reach". A failed fetch ("Failed to fetch" in Chromium, "Load failed" in WebKit, Firefox's "NetworkError…"), a proxy's HTML page or a bare status text keeps "OpenBot couldn't reach its backend…".
  • A later run of a turn the backend refused no longer says the backend stopped answering: "OpenBot's backend couldn't carry on this turn, so the Bot stopped before it finished. What it saved is shown here."
  • botNoLongerUsable (app/src/lib/agents/queries.ts) now throws when the read of the Bot fails any way but 404, so a failed read is never taken to mean the Bot is still there and "setup isn't finished" is only said when the server answered both.

The raw body still goes to the console and the troubleshooting log, with the request id when the body has one. No new screen, component or style: the same stopped-turn notice, with a true sentence.

Where it runs

  • New state that outlives a request? None.
  • What happens on the second replica? Nothing different; this is the browser's reading of a response.
  • 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: nothing changes on the server.
  • New refusals and new failures each write a row: none new.
  • Nothing new is trusted from the client.

API and database

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

Changelog

Conversations.

  • A message the backend refused no longer says OpenBot couldn't reach its backend. When the backend answered, the conversation says what happened: the server's own reason where it gave one, "This Bot can't run because its setup isn't finished" for a Bot the backend can't build, or that the backend couldn't start the turn. "Couldn't reach its backend" is kept for when nothing answered.

Proof

Red on main, green with the fix (origin/main's stopped-turn.ts and queries.ts put back, the new tests run, then the fix restored):

  • app/tests/stopped-turn.test.ts + app/tests/channel-failed-run-restore.test.tsx: main 39 pass, 7 fail; fix 46 pass, 0 fail. On main each failing case received "OpenBot couldn't reach its backend, so your message wasn't sent. Try again, or quit and reopen OpenBot." for the exact 404 body Cloud sent, a 403 {"error":"Forbidden"}, a 409 lock body, a non-OpenBot problem and a 500 problem.

  • app/tests/run-refused-browser.test.tsx (new, real browser): the real conversation in the app's frame with the app's runtime client over the Intelligence transport, against a local HTTP server answering the API and runtime addresses. Four cases × Chromium and WebKit × 1280 and 390 px: the 404 Cloud sent, the run gate's 403 problem, a 403 with no sentence, and no answer at all (the run request aborted, so each engine's own fetch error). Main: 8 pass, 8 fail (both refusal cases in both engines showed the false sentence). Fix: 16 pass, 0 fail.

    OPENBOT_APP_BROWSER=1 OPENBOT_APP_ENGINES=chromium,webkit bun test app/tests/run-refused-browser.test.tsx
    
  • Screenshots, before and after, Chromium and WebKit, 1280 and 390: the notice is the same component in the same place, inside the window, nothing sideways. Before, the 404 case read "OpenBot couldn't reach its backend, so your message wasn't sent. Try again, or quit and reopen OpenBot."; after, "This Bot can't run because its setup isn't finished, so your message wasn't sent. Its owner or an admin can finish it in Setup.", wrapping to three lines at 390 px like every other notice. The no-answer case is unchanged in both engines.

  • Neighbouring suites pass: desktop-problems, organization-unavailable-chat, conversation-access-ended, carried-turn, carry-on-carried-turn-browser, plan-free-trial, too-many-requests-rules, and the copy rules under tests/. tsc --noEmit, biome format and biome lint --error-on-warnings are clean.

A run the backend answered and refused was told to the person as
"OpenBot couldn't reach its backend, so your message wasn't sent. Try
again, or quit and reopen OpenBot." CopilotKit's Intelligence agent
throws every failed run request as `REST run request failed: <body>`,
status gone, and every such failure was read as the backend being out of
reach.

Found on OpenBot Cloud 1.2.9 with OpenBot Desktop 1.2.0-rc.5: each run
of a public Bot the runtime couldn't build was answered 404 with the
runtime's own `{"error":"Agent not found",...}` while the API still
listed the Bot and read it back, and the person read the false sentence
three times.

Now the body decides. A JSON body is the backend answering:
- an OpenBot problem with a sentence for the person is shown as before;
- "Agent not found" for a Bot the server still reads back says the Bot
  can't run because its setup isn't finished, and who can finish it;
- anything else says the backend couldn't start the turn, with "ask an
  admin if it keeps happening".
Only a failed fetch ("Failed to fetch", "Load failed"), a proxy's page or
a bare status text keeps "couldn't reach its backend". A later run of a
turn the backend refused no longer says the backend stopped answering.

botNoLongerUsable now throws when the read of the Bot fails any way other
than 404, so a failed read is never taken as the Bot still being there.
…efused-run tests

Adding run-refused-browser to the WebKit job moved sidebar-current-row
from shard 1 to shard 2, among other neighbours. There its first WebKit
test failed twice running with "Target page, context or browser has been
closed", the WebKit-on-Linux compositor crash under CI's load that
renderer-crash.ts runs again. The file took bun's own test, so the crash
failed the job. It passes alone, and on that shard locally.

Both files now take `test` from renderer-crash.ts. The refused-run test
also runs at a phone's width only for the not-built case, the longest
sentence: 10 pages where it opened 16.
@davidmckayv
davidmckayv marked this pull request as ready for review December 3, 2026 20:59

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