Skip to content

fix(ai): retry upstream availability failures#323

Closed
minpeter wants to merge 1 commit into
code-yeongyu:mainfrom
minpeter:fix/upstream-unavailable-retry
Closed

fix(ai): retry upstream availability failures#323
minpeter wants to merge 1 commit into
code-yeongyu:mainfrom
minpeter:fix/upstream-unavailable-retry

Conversation

@minpeter

@minpeter minpeter commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • classify the exact upstream_unavailable provider code as transient and retryable
  • keep context overflow, refusals, sensitive output, quota, billing, and generic unknown errors excluded
  • prove both the provider-neutral classifier and the no-fallback same-model AgentSession path

This is an independent PR based directly on current main.

Reported failure

Error: upstream_unavailable: Codex upstream websocket send failed via proxy endpoint unknown: ConnectionClosedOK

The existing classifier covered HTTP 503, service-unavailable text, network errors, and narrow WebSocket close
wording, but not the structured upstream_unavailable code. Without a configured fallback chain the turn therefore
settled immediately instead of entering the bounded same-model retry policy.

RED -> GREEN

  • RED classifier: expected retryable true, received false
  • RED AgentSession: expected one auto_retry_start, received none; one provider call only
  • GREEN: exact token \bupstream_unavailable\b admitted
  • GREEN classifier: 7/7
  • GREEN retry/fallback engine: 7/7
  • full AI package suite: 1,191 passed / 761 skipped

Real-surface QA

A local OpenAI Responses server emitted the exact response.failed code/message once, then a successful response.
The real source CLI:

  • exited 0
  • made exactly two provider requests
  • printed the recovery marker
  • used only localhost and a dummy local key
  • left the real auth file unchanged
  • removed its sandbox and closed its server

Root build and npm run check also passed.


Summary by cubic

Classifies the exact upstream_unavailable provider error as transient and retryable, so Codex upstream WebSocket send failures trigger the bounded same-model retry policy instead of failing immediately. Non-retryable cases (quota/billing, context overflow, refusals, sensitive output, and generic unknowns) remain excluded; tests validate the provider-neutral classifier and the no-fallback AgentSession path.

Written for commit 8b9d28a. Summary will update on new commits.

Review in cubic

@minpeter

Copy link
Copy Markdown
Contributor Author

Superseded by current-main Draft PR #330: #330. #330 preserves the exact retry behavior, updates the merged retry event-contract fixture, and avoids force-pushing this stale branch.

@minpeter minpeter closed this Jul 24, 2026
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