Skip to content

fix(cron): stop retrying permanent billing errors returned as HTTP 429 - #114113

Merged
steipete merged 1 commit into
mainfrom
codex/autoqa-cron-billing-429-354c6db7
Aug 9, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/autoqa-cron-billing-429-354c6db7

Conversation

@steipete

@steipete steipete commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Scheduled jobs treated an exhausted balance or spending limit as transient whenever the provider's permanent billing diagnostic also contained HTTP 429. That caused needless model attempts and kept unrecoverable cron work in the retry path.

Why This Change Was Made

The provider already classifies the response before cron receives it. Cron now treats every current structured classification as authoritative: allowed transient reasons retain backoff, while all other classified reasons terminate without falling through to message regexes. This fixes the complete invariant rather than special-casing xAI or one billing string, and leaves the existing raw-text fallback for unclassified failures.

The previous PR diff was discarded because it predated later rate-limit hardening and rewrote an unrelated 40-job admission test. The new boundary test targets the retry owner directly. The latest ClawSweeper review had no Rank-up moves: section or patch finding; this maintainer repair accepts its stated availability boundary that provider-classified billing is terminal.

One adjacent bounded behavior remains intentionally separate: the lower-level agent-session retry classifier can make up to three raw-message retries before provider classification reaches cron. It does not own cron rescheduling and cannot consume this structured result today; unifying that inner classifier is follow-up work rather than a second behavior change in this PR.

User Impact

Permanent provider billing failures stop after the failed scheduled run instead of being rescheduled as rate limits. Genuine provider-classified rate limits keep their existing backoff and retry behavior.

Evidence

  • Current-main failure is src/cron/retry-hint.ts:63: a non-transient structured reason fell through to RATE_LIMIT_PATTERN and became retryable from incidental 429 text.
  • Fail-first command: node scripts/run-vitest.mjs src/cron/retry-hint.test.ts src/cron/service/timer-trigger.test.ts -> 2 failed, 11 passed. Both failures showed billing classified as rate_limit with a 30-second retry.
  • Fixed command: node scripts/run-vitest.mjs src/cron/retry-hint.test.ts src/cron/service/timer-trigger.test.ts -> 2 files passed, 13 tests passed.
  • git diff --check passed.
  • Isolated Codex autoreview completed in one round with no accepted/actionable findings and 0.99 confidence.
  • Production delta: +10/-5. Test delta: +43/-0.
  • Exact-head CI run 31328754637 is green on attempt 2, including check-dependencies, typechecks, lint, guards, build artifacts, SQLite boundaries, and the aggregate openclaw/ci-gate. Attempt 1 had one unrelated ordering flake in workspace-sync-tunnel.test.ts; the unchanged failed-job rerun passed.

@steipete
steipete marked this pull request as ready for review July 26, 2026 13:46
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 26, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Jul 26, 2026
@clawsweeper

clawsweeper Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 1:50 PM ET / 17:50 UTC.

ClawSweeper review

What this changes

The PR prevents scheduled jobs from retrying a billing-classified provider failure merely because its error text contains HTTP 429.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No blocking correctness or security finding: the patch repairs the cron retry owner and should remain open for maintainer merge review and exact-head CI.

Priority: P1
Reviewed head: 54794c89fe217e7e8e789f56d5cb2d6aa0ef7a68
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The patch is a focused owner-boundary repair with direct regression coverage and no actionable review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless records focused fail-first and after-fix test output.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless records focused fail-first and after-fix test output.
Evidence reviewed 7 items Current-main defect: A non-transient classified reason falls through to raw HTTP/message patterns, allowing billing text containing 429 to be retried.
Producer-to-owner path: Cron records the derived reason before scheduling and passes it to the retry decision on both one-shot and recurring paths.
Provider classification contract: The provider classifier recognizes billing semantics before generic 429 rate-limit handling; focused tests cover the billing classification.
Findings None None.
Security None None.

How this fits together

Cron stores the provider-derived failure reason for a completed scheduled run, then decides whether to retry it with backoff or record a terminal outcome. This change makes that structured reason take precedence over raw error-text matching.

flowchart LR
  A[Provider error text] --> B[Failure classification]
  B --> C[Cron job outcome]
  C --> D[Retry decision]
  D --> E{Allowed transient reason?}
  E -->|Yes| F[Backoff and retry]
  E -->|No| G[Terminal cron outcome]
Loading

Decision needed

Question Recommendation
Should cron continue to treat the maintained provider classification as authoritative when choosing terminal failure versus retry? Keep classifications authoritative: Merge the terminal handling for non-transient classified reasons once exact-head CI is green.

Why: This is an intentional availability tradeoff: accepting a classified billing reason prevents wasteful retries, while a future classifier error could suppress recovery.

Before merge

  • Resolve merge risk (P1) - The change intentionally makes provider classification the availability boundary: an incorrect future billing classification would suppress a retry, so merge should retain focused classification coverage and require exact-head CI.
  • Resolve merge risk (P1) - The aggregate check currently reports an unrelated default-branch UI dependency-pin violation; this four-file branch still needs a clean exact-head required-CI result before merge.
  • Complete next step (P2) - No mechanical repair remains; a maintainer must accept the availability boundary and merge only after exact-head CI is green.
Agent review details

Security

None.

PR surface

Source +5, Tests +43. Total +48 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 10 5 +5
Tests 2 43 0 +43
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 53 5 +48

Review metrics

Metric Value Why it matters
Production versus test delta production +10/-5; tests +43/-0 The net production growth is the typed authoritative decision boundary; the test growth covers billing-versus-rate-limit behavior.

Merge-risk options

Maintainer options:

  1. Accept the typed retry boundary (recommended)
    Merge after exact-head CI confirms the current classifier contract, making classified billing failures terminal while preserving rate-limit backoff.
  2. Pause for classifier policy revision
    Do not merge if maintainers want raw error text to override a permanent classification; that policy requires a different retry contract.

Technical review

Best possible solution:

Adopt structured provider classification as cron’s canonical retry boundary, retaining raw-text matching only when no classification exists, after exact-head CI is green.

Do we have a high-confidence way to reproduce the issue?

Yes. The PR records a focused current-main fail-first run where billing text with HTTP 429 was retried, and the current retry-hint fallthrough directly explains that result.

Is this the best way to solve the issue?

Yes. The retry owner already receives the derived provider reason, so making that reason authoritative is narrower and safer than adding provider-specific message exceptions or changing the separate agent-attempt loop.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 72283e440e07.

Labels

Label justifications:

  • P1: The patch fixes needless retrying of scheduled jobs after a permanent provider billing failure.
  • merge-risk: 🚨 availability: A wrong provider classification could turn an otherwise retryable scheduled failure into a terminal outcome.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless records focused fail-first and after-fix test output.

Evidence

What I checked:

Likely related people:

  • steipete: Recent merged cron scheduler and timer lifecycle work, plus the proposed repair, place this person closest to the current owner boundary. (role: recent cron scheduler contributor; confidence: high; commits: 73aa80a632a1, 06776e707b44, 2a895ca8dbfb; files: src/cron/retry-hint.ts, src/cron/service/timer-outcomes.ts)
  • g515hoshino: Blame attributes the pre-PR retry fallthrough to the cron baseline carried by the grafted commit. (role: baseline retry-path contributor; confidence: medium; commits: 3ee6c6a3e1; files: src/cron/retry-hint.ts, src/cron/service/timer-trigger.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-07-26T13:51:08.855Z sha 725b9a6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T13:27:51.471Z sha 725b9a6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T06:57:22.840Z sha 725b9a6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T07:08:07.744Z sha 725b9a6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-02T11:18:02.630Z sha 725b9a6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T12:40:49.405Z sha 725b9a6 :: needs maintainer review before merge. :: none
  • reviewed August 8, 2026, 3:44 PM ET / 19:44 UTC sha unknown :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 2, 2026
@steipete
steipete force-pushed the codex/autoqa-cron-billing-429-354c6db7 branch from 725b9a6 to 54794c8 Compare August 9, 2026 17:17
@steipete
steipete force-pushed the codex/autoqa-cron-billing-429-354c6db7 branch from 54794c8 to a3c4060 Compare August 9, 2026 18:19
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready verification on exact head a3c40602a426f8d309b0df1312294b0d5be26994:

  • Rebased cleanly onto current main; production delta remains +10/-5 and tests +43/-0.
  • Fail-first regression: 2 failed / 11 passed before the owner fix; focused after-fix and post-rebase run: 13/13 passed.
  • git diff --check origin/main...HEAD passed.
  • Fresh isolated Codex autoreview completed with no accepted/actionable findings.
  • Exact-head CI run https://github.com/openclaw/openclaw/actions/runs/31328754637 is green on attempt 2, including the aggregate gate. Attempt 1 had one unrelated gateway ordering flake; the unchanged failed-job rerun passed.
  • Latest ClawSweeper review has no patch finding or Rank-up move; its availability-boundary recommendation is accepted for this maintainer repair.
  • Native review artifacts validate as READY FOR /prepare-pr, and OPENCLAW_TESTBOX=1 scripts/pr prepare-run 114113 completed successfully.

The canonical fix makes current typed provider classifications authoritative at cron's retry owner: billing is terminal, genuine rate limits retain backoff, and unclassified failures retain the existing text fallback.

@steipete
steipete merged commit e86512f into main Aug 9, 2026
196 of 198 checks passed
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/autoqa-cron-billing-429-354c6db7 branch August 9, 2026 18:40
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant