Repository navigation
Dream: retry reservation 429s inside the pass and shorten the 3.8 cooldown - #23085
Conversation
Retry the pending planner/verifier call within the existing session and deadline, with bounded jitter and fresh lease, capacity and per-attempt budget checks. Use a 10-second local/shared 3.8 saturation cooldown while retaining legacy policy. Settle known-zero rejections and preserve reported or conservative attempt usage. Cover burst recovery, peer cooldowns, budget settlement, deadlines and cancellation. Failure-Class: none Co-Authored-By: Codex Sol <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Release known-zero attempt minute holds without persisting a receipt or consuming the receipt cap. Preserve billed and unknown usage accounting. Record model lanes only after a completed model call so retries do not inflate reported turns. Cover 64-turn heavy passes with repeated bare 429s and no-dispatch waits, including exhausted retries, and full receipt-cap billing boundaries. Validation: backend/test.sh, eight targeted files, 589 passed and one deselected; final retry suite rerun passes the CPU duration guard. Co-Authored-By: Codex Sol <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d16f0dbe6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if known_zero and not isinstance(aggregate, dict) and on_usage is not None: | ||
| await on_usage(_zero_turn()) |
There was a problem hiding this comment.
Refund known-zero gateway capacity receipts
The production gateway always adds a dream_usage.attempt_usage entry for a resolved Dream route, including a dedicated-capacity 429. That entry has zero tokens, usage_complete=false, and unknown_attempts=0, but turn_from_usage() passes it to charge_attempts(), which treats every incomplete entry as a full-ceiling charge. Consequently this new missing-aggregate-only refund branch is skipped, each known-zero reservation rejection consumes the full token/USD budget, and repeated retries can terminate for budget exhaustion instead of recovering. Recognize the gateway's known-zero attempt class in the aggregate path and settle it as zero.
Useful? React with 👍 / 👎.
| async def invoke(lane, mount, messages): | ||
| for attempt in range(CAPACITY_CALL_RETRIES + 1): | ||
| try: | ||
| return await invoke_once(lane, mount, messages) | ||
| except dream_harness_transport.CapacityWait as exc: |
There was a problem hiding this comment.
Keep zero-capacity retries out of the turn receipt cap
Each retryable rejection is settled through on_usage before this loop retries, and dream_turns.settle() appends even a zero-valued settlement to turn_receipts, whose hard limit is 128. A valid 64-turn session can already use up to 114 receipts after verifier batches, so only 15 intermittent capacity retries can raise dream_turn_cap and fail the entire pass despite consuming no model tokens. Zero/refund-only retries need to release the minute hold without consuming a persisted turn-receipt slot.
Useful? React with 👍 / 👎.
| except dream_harness_transport.CapacityWait as exc: | ||
| if not exc.retryable or attempt == CAPACITY_CALL_RETRIES: | ||
| raise |
There was a problem hiding this comment.
Propagate exhausted verifier capacity waits
When all six attempts for a verifier call remain capacity-blocked, this re-raises CapacityWait, but dream_verify.verify_two() catches every Exception and converts it into a None vote. The pass then records the default-policy proposals as unverified, reports the pass complete, and finishes the dirty inputs as successfully reviewed instead of returning the advertised capacity-wait outcome; thus a sustained 429 during verification still permanently discards the staged work these retries are intended to preserve. Let verifier orchestration propagate CapacityWait after retry exhaustion.
Useful? React with 👍 / 👎.
| for attempt in range(6): | ||
| ceiling = min(30, COOLDOWN_SECONDS * 2**attempt) | ||
| pause = random.uniform(ceiling / 2, ceiling) |
There was a problem hiding this comment.
Wait through the local cooldown before the first recheck
After a request 429, mark_saturated() has just set this process's local cooldown to 10 seconds, while the first jittered pause here is only 5–10 seconds. Except for the exact upper endpoint plus scheduling delay, the first available_model() call is therefore guaranteed to reject on that local cooldown, wasting one of the six checks and forcing another 10–20-second sleep; a nominal 10-second cooldown consequently delays the first real retry for 15–30 seconds. Schedule the first check no earlier than the known local expiry, or avoid counting guaranteed-local-cooldown checks against the retry budget.
Useful? React with 👍 / 👎.
…CI runners Co-Authored-By: Claude Opus 5.5 <[email protected]>
Counting lanes only on a clean return dropped completed calls whose payload then failed to parse, which made the canary read a healthy malformed-verifier response as a model failure. Count on return, or once the transport completed; zero-cost capacity retries never complete and stay uncounted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the CPU guard (2nd trip) 1.16-1.28s CPU on integration CI shard 2 in two consecutive runs of #23133 (0.25s locally; green on main's shards). Second trip -> allowlist per the lane-1 flake policy, with a removal note. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
On 2026-10-21, prod was at 5% of paid owners with
DREAM_AGENT_CONCURRENCY=8, reserved-only on gemini-3.8-flash. The 18:00Z Dream sweep loggedcandidates=206 complete=0 failed=0 waiting=203. Nothing failed, but nothing completed either.Cause (Codex Sol, from code and masked logs).
dream_harness_transportmarked saturation and raisedCapacityWaitimmediately. The pass was abandoned with no checkpoint, so the next attempt started a fresh session.wait_for_capacity, had no production caller.CapacityWaitreports discarded about 3.15M tokens of partial work.complete=0is real, not an undercount: the drain cancels itsTaskGroupat the deadline, and the only completion between 18:28 and 18:45Z was the synthetic canary.Fix.
Review
GLM-5.3 (zcode) returned SHIP-WITH-NITS. It confirmed:
Findings and what happened to them:
waitingintofailed;turnscounts completed calls, not attempts.waitingreports;verifier_unverifiedmapping is unchanged (pre-existing).Verification
Codex Sol ran
backend/test.shwith targeted file lists, under nice/taskpolicy with 2 workers:These are unit results only. Prod verification is the next sweep's
complete=count, 429 retry pressure and dedicated-only 3.8 usage.Re-ramp
After deploy, the 5% hold restarts. It needs a sweep with real completions and failed<2/h. Concurrency stays at 8 for the 25% step.
Product invariants affected
none
Failure class
Failure-Class: none
🤖 Generated with Claude Code