fix(failover): fallback on replay-safe prompt timeouts#96142
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 25, 2026, 5:22 PM ET / 21:22 UTC. Summary PR surface: Source +17, Tests +137. Total +154 across 4 files. Reproducibility: yes. at source level: current main and v2026.6.10 return Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this replay-safe implementation or an equivalent maintainer-chosen patch as the canonical fix while preserving Codex app-server and replay-invalid timeout isolation. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main and v2026.6.10 return Is this the best way to solve the issue? Yes: this is narrower than a simple AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 13ecca5408cb. Label changesLabel justifications:
Evidence reviewedPR surface: Source +17, Tests +137. Total +154 across 4 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
(cherry picked from commit 0da2649)
(cherry picked from commit 0da2649)
Closes #95574
Recreates and repairs #95576.
What Problem This Solves
Fixes an issue where replay-safe prompt-stage provider timeouts could surface as terminal errors even when model fallbacks were configured for the run.
Why This Change Was Made
The failover policy now allows model fallback for harness-owned timeout errors only when the timeout is from the prompt request, the attempt is replay-safe, the harness has not marked the timeout replay-invalid, and the failure is not a Codex app-server transport failure. Plugin harness lifecycle and abandoned-turn timeouts stay inside the existing surface-error path.
User Impact
Runs with configured fallback models can recover from safe provider prompt timeouts without replaying abandoned or side-effectful work.
Evidence
Focused local proof:
Result: passed, 46 tests across 3 files.
Result: passed.
Autoreview initially found a replay-invalid timeout gap; fixed by gating on
attempt.promptTimeoutOutcome?.replayInvalid !== trueand adding a regression test.Final autoreview:
Result: clean, no accepted/actionable findings.
Crabbox/Testbox changed-scope proof:
provider=blacksmith-testbox),tbx_01kvtkmff6an4nytrtbpxctrha365bfa1e92eec80256e9f028cc9e7db2095c37ecd095d98a02b99a8ad0f42f128367b5ae2a99ea5aExact command run on the Testbox after checking out
brokemac79:codex/recreate-95576-failover-timeout:Result: passed,
TESTBOX_EXIT=0.Relevant output:
Azure Crabbox changed gate also passed on the pushed head
365bfa1e92eec80256e9f028cc9e7db2095c37ec:The Azure changed gate included guarded extension wildcard re-export checks, plugin-sdk wildcard re-export checks, dependency pin guard, npm shrinkwrap guard, runtime sidecar baseline/owner test, package patch guard, database-first legacy-store guard, media download helper guard, runtime sidecar loader guard, all changed-scope typecheck, lint shards, and runtime import cycle check.
Real behavior proof: prompt-stage timeout fallback
Behavior or issue addressed: after a replay-safe prompt-stage timeout from the primary model,
runWithModelFallbackretries the configured fallback model instead of ending the run with the timeout error.Real environment tested: Crabbox
provider=local-containeron this Windows desktop, Docker imagemcr.microsoft.com/playwright:v1.60.0-noble, leasecbx_667e40085f52, slugquick-prawn, PR head365bfa1e92eec80256e9f028cc9e7db2095c37ec.Exact steps or command run after this patch:
Evidence after fix: the proof harness uses the production
runWithModelFallbackloop and productionrunEmbeddedAgentpath with a registered plugin harness. The primary configured model returns a prompt-stage timeout outcome; the fallback configured model completes.Observed result after fix: the prompt timeout is classified as prompt-stage and replay-safe, the configured fallback
openai/fallback-okis attempted, and the run completes on the fallback model after two attempts.Supplemental validation:
Supplemental desktop Ollama proof:
http://127.0.0.1:11434, modelqwen3.5:4b, PR head365bfa1e92eec80256e9f028cc9e7db2095c37ec.ollama-timeout/qwen3.5:4bpointed athttp://10.255.255.1:11434with a 1 second timeout; configured fallbackollama/qwen3.5:4bpointed at the local Ollama server withlocalModelLean: trueand a 262144-token declared context window.Exact command run after this patch:
Evidence after fix:
Observed result after fix:
{ "payloads": [{ "text": "proof-ok", "mediaUrl": null }], "meta": { "agentMeta": { "provider": "ollama", "model": "qwen3.5:4b", "contextTokens": 262144, "fallbackAttempts": [ { "provider": "ollama-timeout", "model": "qwen3.5:4b", "error": "LLM idle timeout (1s): no response from model", "reason": "timeout", "status": 408 } ] }, "finalAssistantVisibleText": "proof-ok" } }Proof limitations or environment constraints: the local-container proof uses a deterministic registered OpenClaw plugin harness. The supplemental desktop proof exercises a real local Ollama server and a real fetch timeout to an unreachable Ollama endpoint from the same Windows host, but it does not prove a remote Crabbox VM can reach this desktop's loopback Ollama service.
What was not tested: live third-party cloud provider auth, an actual external provider outage, and remote Crabbox-to-desktop Ollama tunneling were not exercised.