Skip to content

Bound Codex recovery and reconnect interrupted thinking streams - #158

Open
diastidean wants to merge 4 commits into
raine:mainfrom
diastidean:feat/session-fast-recovery
Open

diastidean wants to merge 4 commits into
raine:mainfrom
diastidean:feat/session-fast-recovery

Conversation

@diastidean

Copy link
Copy Markdown

Summary

A Codex WebSocket reset after reasoning had begun terminated the Claude Code turn even when no answer text or tool call had reached the client. Empty completions could also spend more than 157 seconds in ten retry backoffs and then trigger another retry loop in the client.

This change:

  • Reconnects transient WebSocket failures after thinking-only output using a full-context request, while preserving one downstream message and unique content-block indices.
  • Bounds connection recovery to three reconnect attempts and a 60-second retry window. The initial generation is not subject to that new deadline.
  • Does not replay partial answer text or tool arguments; preserves the existing completed-tool handoff and returns an explicit error when replay is unsafe.
  • Limits empty completions to two retries and marks exhausted recovery with x-should-retry: false so clients do not multiply it into another retry loop.
  • Logs retries, restoration, and exhaustion. Opt-in launch-scoped notices use a validated x-clodex-notification-id, allowing the companion launcher to display progress without inserting it into assistant output.
  • Preserves the priority tier when automatic review requests are routed to another supported Codex model, and recognizes claude-fable-5-1.

Companion launcher PR: DeanDiasti/clodex#10

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --locked -- -D warnings
  • cargo test --all-targets --locked
  • Fault-injection tests cover a reset without a closing handshake after thinking, bounded repeated resets, and no replay after partial text or tool arguments.
  • On the pre-merge local build, an end-to-end fixture through the installed Claude Code CLI recovered from the exact reset with two upstream requests, a successful final answer, and separate reconnect/restored stderr notices.

The branch incorporates current upstream main and preserves its release version and quota-error metadata. Local binary deployment is separate from this PR.

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