Skip to content

fix(threads): keep provider failures with their own turn - #530

Merged
nixuuu merged 1 commit into
devfrom
fix/non-fatal-provider-error
Nov 10, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/non-fatal-provider-error

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 10, 2026

Copy link
Copy Markdown
Member

When a failed Codex turn receives late output after a background wake-up starts, its work is grouped above the new turn but its failure footer can remain at the bottom. Keep the footer with its own work, and prevent advisory idle/systemError activity from idling a thread that still has a running turn.

Codex error notifications already map to diagnostic notices, including willRetry: false; only turn/completed determines the outcome. Preserve that contract and genuine terminal failures. Web and mobile now show readable provider error summaries with redacted JSON behind Show details, including previously saved notices.

Transport investigation

  • Canopy uses turn/steer for steering and turn/interrupt for Stop. Steering is not interrupt + restart.
  • Codex 0.164.0 itself sends response.interrupt over Responses WebSockets, including during its default instant-interrupt steering path. CLIProxyAPI has a documented late-interrupt race that returns this 400 and can poison the next response. Sources and the distinction from a missing WebSocket capability are in docs/proxies.md.
  • New proxy connections default to HTTP/SSE. Explicit saved WebSocket settings remain honored. Existing affected connections need Supports WebSockets disabled; the change applies after instance drain. Connection testing checks the model catalog, not interruption compatibility.
  • worker_shutdown means background processes stopped for a worker restart/deploy. The existing recovery tests and new gRPC regression cover the resulting wake-up. It does not establish that the restart caused the provider error. Without incident events and the proxy version, the screenshot's exact sequence remains unconfirmed.

Validation

  • Passed frozen dependency install, generated-code check, monorepo typecheck, lint, formatting check and web production build.
  • Adapter regressions: both retry flags followed by work and success; true terminal failure; a new wake-up turn and late old-turn output; redaction of endpoint and credential details. Sequences are scripted app-server notifications, not an incident recording.
  • Real gateway/Postgres/worker gRPC regression checks live and reloaded statuses, web footer order, mobile turn order, worker_shutdown wake-up and repeated late terminal/activity events. Existing Codex mapping/turn-boundary, proxy, worker-restart, background-task, durability and report-order files also passed individually.
  • Full check:tmp ran once with concurrency limited to 1: 2,221 passed, 163 skipped and 2 failed across 408 files; the temp-directory check was clean. Both failures passed on targeted reruns: the existing launch expectation needed the new explicit supports_websockets=false argument, and worker-profile-env.test.ts needed my CANOPY_LIVE=0 invocation override removed (the fixture checks exact inherited environment keys). No production change was required for either. The full suite was not repeated. Opt-in live inference was skipped; the real Codex app-server/fake-inference connection-resume test passed.
  • Chromium visual inspection: 1440 px desktop in light/dark, 820 px narrow, 390 px phone in light/dark; short, typical and long notices, collapsed/expanded details, copy control and historical failure above running work. Temporary fixture removed. Native mobile rendering was not run; mobile typecheck and shared presentation/order coverage passed. No component or E2E suites added.

Copy audit (§8)

  • Raw error JSON → Provider error 400: no active upstream websocket for response.interrupt, with the raw payload behind Show details and a copy action. This follows the requested diagnostic wording; response.interrupt is retained as the provider's literal message, not an invented user-facing term. Summaries and details redact endpoints and credentials.
  • Enable when the upstream supports Codex Responses over WebSockets. → Use HTTP streaming unless the proxy supports Codex WebSocket interruptions. One sentence, 10 words, a concrete condition for the advanced setting.
  • Reused Show details, Copy error details, and Error details. Actions start with verbs; sentence case, glossary, non-color cues and wrapping checked. No new empty states, confirmations, duplicate explanations or humor.

Fixes: #72
Related: #527

Keep late old-turn failure footers above newer running work and prevent
advisory idle activity from idling an active turn. Present provider JSON
notices as readable, redacted summaries with details on demand.

Default new proxy connections to HTTP streaming to avoid Responses
WebSocket interrupt races while preserving explicit transport choices.

Fixes: #72
Related: #527
@nixuuu
nixuuu merged commit ab7bfd3 into dev Nov 10, 2026
9 checks passed
@nixuuu
nixuuu deleted the fix/non-fatal-provider-error branch November 10, 2026 21:38
nixuuu added a commit that referenced this pull request Nov 12, 2026
nixuuu added a commit that referenced this pull request Nov 12, 2026
nixuuu added a commit that referenced this pull request Nov 12, 2026
nixuuu added a commit that referenced this pull request Nov 12, 2026
Retrying a failed turn now sends exactly **Continue**, without copying
the original request into the user bubble. Once a later turn starts, the
older failure becomes a compact title and **Show details** entry. Its
explanation, hints, recovery actions and retry feedback disappear
immediately, using the existing feed anchoring without a height
animation. Queued messages do not hide actions before dispatch.

Mobile gets the same compact historical failure entry through JS-only
changes. It already has no retry/settings buttons in thread failure
cards. No native configuration or dependencies changed.

## Session recovery

Existing provider sessions retain their own context. The worker saves
the latest substantive request privately in its SQLite journal,
surviving event ACKs and restarts. If Retry needs a fresh Codex session
because its rollout is missing, or a fresh Claude session because its
transcript is missing, the request is supplied as developer/system
context with a reminder to inspect completed side effects. The user
message stays **Continue**. Grok requires a successful session load and
has no silent empty-session fallback.

This fallback restores the saved request, not a complete lost provider
transcript. Requests predating this worker change have no private
recovery copy.

## Validation

- Rebased onto `dev` at `a73e5c1bf`. Resolved the mobile `TimelineTurn`
conflict by retaining #554's `TimelineDisclosure`, UI-thread anchoring
and local group state. Historical failure state now passes through
`ThreadTimeline`'s memoized cell, including its equality check, so an
older card updates when a new turn starts. Web retains #554's
`VirtualFeed.keep` behavior for the latest summary. No disclosure or
motion changes were reverted.
- `bun install` and `bun run gen:check` pass on the final head. Focused
worker tests pass: **5 tests, 28 assertions**, covering native session
resumption, missing-rollout recovery, journal ACKs/restarts, repeated
retries, request replacement and thread isolation. The emitted user
message is exactly **Continue** and excludes the prior request. No web
UI tests added.
- After conflict resolution, `bun run format`, `bun run lint`, mobile
typecheck, `bun install`, generated-code checks and the 5 focused tests
pass. GitHub CI runs the final head's static checks, build and full test
shards. The full local `check:tmp` was not repeated, as requested.
- Real-browser review used an isolated gateway/PostgreSQL fixture,
scripted worker, and the real web BFF/SSE. Checked light and dark at
**1440 × 900** and **390 × 844**: initial failure recovery actions;
Retry bubble exactly **Continue**; compact historical failure during
streaming; latest failure retaining actions; and working **Show
details**. Sending an ordinary new message also removes older actions.
No horizontal overflow. Frame sampling around Retry kept the failure
title at **y = 212 px** while its card changed directly from **148 px to
56 px**, with no intermediate height animation. Navigation cancellation
logged a thread-watch warning; subsequent streams and sends succeeded.
- EAS production-profile fingerprints match final head and `dev`,
generated with identical checkout paths and installed dependencies: iOS
**`6ddec9ef559ee0095ac33e94ff9418a942053b17`**, Android
**`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`**. No native-device visual
review is claimed. The browser tab, web server, gateway and disposable
database were stopped after review.
- Repeated the real-browser failure-card check after conflict resolution
at 1280 × 800 light and 390 × 844 dark: **Continue** only, compact older
cards during a new turn/streaming, working details, latest failure
recovery actions, and no horizontal overflow. Recomputed both EAS
fingerprints against this new base; both hashes above remain identical.
All disposable processes and the browser tab were stopped again.

## Copy audit — docs/copy.md §8

- **Continue the previous request after the failed turn. Check what was
already done before repeating anything with side effects. Previous
request: <original prompt>** → **Continue**. One imperative, one word,
sentence case, no duplicated request or internal jargon in the user
bubble.
- Reused **Could not finish this turn**, **Show details**, **Copy error
details** and existing action labels. Historical failures stop asking
for action after work resumes; technical details remain available on
demand. No new glossary terms, empty states, confirmations, duplicate
facts or humor. Text supplies meaning independently of color or icons.
- Visual copy audit: checked the short **Continue** bubble, a multiline
original request, and wrapping failure explanation/action labels at
desktop and phone widths, light and dark. Changed failure copy contains
no interpolated user names. Existing long labels stay within the phone
width; historical entries retain their title and disclosure.

History inspection (`git log -S`) identifies #94 as the source of the
long Retry message. #530 changed failure grouping/presentation but did
not introduce that text.

Fixes: #94
Related: #530
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