Skip to content

Dream: retry reservation 429s inside the pass and shorten the 3.8 cooldown - #23085

Merged
Git-on-my-level merged 4 commits into
mainfrom
lane/dream-429-resume
Oct 21, 2026
Merged

Git-on-my-level merged 4 commits into
mainfrom
lane/dream-429-resume

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

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 logged candidates=206 complete=0 failed=0 waiting=203. Nothing failed, but nothing completed either.

Cause (Codex Sol, from code and masked logs).

  • When one model call hit a real reservation 429, dream_harness_transport marked saturation and raised CapacityWait immediately. The pass was abandoned with no checkpoint, so the next attempt started a fresh session.
  • A 120 s local cooldown and a Redis saturation marker then parked every worker. The only retry helper, wait_for_capacity, had no production caller.
  • In that hour, 91 token-bearing CapacityWait reports discarded about 3.15M tokens of partial work.
  • complete=0 is real, not an undercount: the drain cancels its TaskGroup at the deadline, and the only completion between 18:28 and 18:45Z was the synthetic canary.

Fix.

  • Retry in place: a 429'd planner or verifier call is retried inside the same session, keeping history, tool results and staged proposals. It gets up to 5 retries with bounded exponential jitter.
  • Checks before each retry: capacity, lease, kill switch and budgets are rechecked, and the pass needs 20 s of headroom. Existing planner, verifier and pass timeouts still apply.
  • Charging: rejections known to cost nothing release their minute hold; paid and unknown usage stays charged.
  • Cooldown: on 3.8, the local and shared cooldown and the worker parking drop from 120 s to 10 s. Legacy 2.5 keeps 120 s.
  • Unchanged: routing stays reserved-only, and the concurrency and minute limits are untouched.
  • Docs: the runbook is updated.

Review

GLM-5.3 (zcode) returned SHIP-WITH-NITS. It confirmed:

  • identical replays, with tools running only after a successful turn;
  • no double charge and no leaked hold;
  • all deadlines honored;
  • reserved-only routing preserved;
  • dispatches fleet-wide still capped by the shared Redis slots, so no 429 storm (worst case is about 8 requests every 15 s).

Findings and what happened to them:

  • Fixed in the second commit:
    • known-zero attempts no longer store receipts against the 128-row turn cap, which could have flipped waiting into failed;
    • turns counts completed calls, not attempts.
  • Accepted as-is:
    • the 10 s re-park raises the volume of waiting reports;
    • verifier_unverified mapping is unchanged (pre-existing).

Verification

Codex Sol ran backend/test.sh with targeted file lists, under nice/taskpolicy with 2 workers:

  • first commit: 326 unique targeted tests passed, plus 771 Firestore guard cases;
  • follow-up commit: 589 passed across 8 targeted files, including 495 Firestore query-shape cases;
  • six regression cases failed on origin/main before the patch;
  • no pinned Firestore function body changed.

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

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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T19:31:36.674350Z 2eaaad6 New commits
ℹ️ 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" or "@codex security review".

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]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +297 to +298
if known_zero and not isinstance(aggregate, dict) and on_usage is not None:
await on_usage(_zero_turn())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines 264 to +268
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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +268 to +270
except dream_harness_transport.CapacityWait as exc:
if not exc.retryable or attempt == CAPACITY_CALL_RETRIES:
raise

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +165 to +167
for attempt in range(6):
ceiling = min(30, COOLDOWN_SECONDS * 2**attempt)
pause = random.uniform(ceiling / 2, ceiling)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Git-on-my-level and others added 2 commits October 22, 2026 02:19
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]>
@Git-on-my-level
Git-on-my-level merged commit 5406315 into main Oct 21, 2026
63 of 66 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/dream-429-resume branch October 21, 2026 20:42
Git-on-my-level added a commit that referenced this pull request Oct 21, 2026
…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]>
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