Repository navigation
fix(review): retry Codex model-capacity failures as provider throttling - #1969
Conversation
OpenAI's 'Selected model is at capacity. Please try a different model.' matched none of the capacity patterns, so those reviews were recorded as non-retryable codex_execution failures with an unknown reason (4 of 5 sampled failures in the 2026-10-13 12:00-14:00 UTC spike). Define the provider capacity pattern once, add 'at capacity', and use it for both the retryable decision and the provider_throttle classification.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review Current proof and validation for head 14c8cd4 are in the PR body. |
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. |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 14c8cd4800
ℹ️ 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".
|
|
||
| // Provider rate limits and capacity errors, including "Selected model is at capacity". | ||
| export const CODEX_PROVIDER_CAPACITY_ERROR = | ||
| /rate limit reached|tokens per min|\bTPM\b|requests per min|\b429\b|temporarily unavailable|overloaded|\bat capacity\b|please try again in \d+(?:\.\d+)?(?:ms|s)/i; |
There was a problem hiding this comment.
Match the complete model-capacity diagnostic
When an item's title or other early report text contains a phrase such as "service is at capacity" and its review fails for an unrelated non-retryable reason, this bare at capacity alternative makes isInfrastructureFailedReview() treat the record as retryable because failedReviewFailureDetail() scans the first 8,000 bytes of the report, including user-controlled front matter. This can repeatedly requeue permanent failures; constrain the matcher to the provider diagnostic (for example, selected model is at capacity) rather than the generic fragment.
Useful? React with 👍 / 👎.
|
@clawsweeper re-review The previous explicit request completed a review in https://github.com/openclaw/clawsweeper/actions/runs/38431373647 (rev 2), but a |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR classifies Codex model-capacity failures as retryable provider throttling while excluding item titles from failed-review retry classification. Example: A failed review contains “ERROR: Selected model is at capacity. Please try a different model.”
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still misses the provider diagnostic, both prior findings are resolved, and no new actionable defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherCodex diagnostics and stored failed-review reports enter shared failure classification, which supplies retry eligibility and failure taxonomy to the review runner and durable retry command. flowchart TD
A[Codex failure diagnostic] --> B[Shared transient matcher]
B --> C[Review failure classification]
D[Stored failed review] --> E[Failure text without titles]
E --> B
B --> F[Retry eligibility gates]
F --> G[Bounded retry dispatch]
Technical reviewBest possible solution: Use the shared provider-diagnostic matcher with title exclusion and preserve the existing terminal-denial and bounded-retry safeguards. Do we have a high-confidence way to reproduce the issue? Current-main source excludes the reported provider diagnostic from both retry matching and capacity classification; the PR supplies corresponding runner and report regressions, but this review did not execute them. Is this the best way to solve the issue? The focused shared matcher and title exclusion address the observed classification failure without adding a competing retry owner or changing retry budgets. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 44696e44b329. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)Reviewed October 13, 2026, 2:16 PM ET / 18:16 UTC (Revision 3). |
Failed-review retry eligibility scans report text that includes the item title, so a bare 'at capacity' would make a permanent failure on an item titled, for example, 'Service is at capacity' retryable. Match the full 'selected model is at capacity' diagnostic and add report-level coverage for both the real diagnostic and the title trap.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9850d3ba89
ℹ️ 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".
| export const CODEX_PROVIDER_CAPACITY_ERROR = | ||
| /rate limit reached|tokens per min|\bTPM\b|requests per min|\b429\b|temporarily unavailable|overloaded|selected model is at capacity|please try again in \d+(?:\.\d+)?(?:ms|s)/i; |
There was a problem hiding this comment.
Restrict capacity matches to trusted failure evidence
When an issue or PR is titled exactly "Selected model is at capacity" and its review fails for an unrelated permanent reason, this pattern still makes the failure retryable because failedReviewFailureDetail() passes the report's first 8,000 bytes—including the user-controlled title—to isRetryableCodexTransportError(). Fresh evidence after the prior comment is that the new negative test covers only the shorter title "Service is at capacity", so it does not exercise the full diagnostic now accepted here. Match this diagnostic only in trusted Codex failure fields rather than report-wide text, otherwise such items consume durable retry attempts despite having no provider failure.
Useful? React with 👍 / 👎.
|
@clawsweeper re-review Resolved the P2 finding: the matcher now requires the full provider diagnostic |
|
🦞👀 Re-review progress:
|
failedReviewFailureDetail scanned the first 8,000 report characters, including the contributor-written title front matter and heading, so an item titled with a provider diagnostic made a permanent failure look retryable. Drop the title and fixed_pr_title front-matter lines and the title heading from that raw-text fallback; failure evidence fields are unchanged.
|
@clawsweeper re-review Resolved the second P2: failed-review retry classification no longer scans the item title (front-matter |
|
🦞👀 Re-review progress:
|
… requeues (#1981) An explicit `@clawsweeper re-review` on a maintainer-authored PR was silently lost when the PR changed while the review ran (on #1969 and again on this PR, another bot's PR review moved the review-activity cursor). Apply skipped publication for source drift, the queue requeued the generation in place as `source_drift_requeue`, and claim admission skipped that retry as an automatic maintainer review, leaving the command status at "Review in progress" and its review lease held for about an hour. - `isExplicitReviewRequest` now accepts a `source_drift_requeue` that still carries the request's command status and verified command fields, so the queue's fenced in-place requeue continues the same request through claim admission and the hosted publication gate. - The queue keeps request verification on a `source_drift_requeue` only when it requeued the generation in place (`direct-lifecycle-requeue:` admission provenance). The rule runs in the load-time normalizer and on `/enqueue`, so a finished or replaced request re-enqueued by a publisher, including rows persisted by the previous release, keeps its status but cannot authorize another review. `/enqueue` rejects caller delivery ids that use the queue-owned prefix (`reserved_delivery_id`). - AGENTS.md, docs/scheduler.md, README, and a changelog fragment state the contract; deferred publications (batch publisher requeues) still need a new request and are tracked in the stacked #1984. Proof: replay of #1969's real rev 2/rev 3 claim decisions through the compiled `live-item` admission step, real queue Durable Object lifetime and upgrade tests, final effects through the real apply owner on an owner-authored oversized PR (continuation writes; finished-request requeue zero writes), and a cross-version run where main persists an orphaned verified requeue and this change claims those bytes as non-explicit.
…mission (#2001) On a maintainer-authored item, a review generation that still carries an explicit command but lacks request authority (for example a fail-closed source_drift_requeue whose verification the queue stripped) is skipped at claim admission. The skip path never created the review job's write token, so "Mark unsuccessful re-review" never ran and the command status stayed "Review in progress" forever, as on #1969; no terminal-finalization driver answers a review generation's policy_noop either. - "Create target write token" now also runs for exactly that case (semantic no-op, maintainer_request_required hold, command context). Every other token consumer stays gated on the review proceeding or on items without command context. - "Mark unsuccessful re-review" answers that case as "Waiting" with a request to re-review. Waiting is deliberately non-terminal, so a later continuation of the same request (#1989's handoff) is not refused. - Both existing queue fences stay: the step's lease heartbeat and the status CLI's authority fence before lookup and before write. Proof: the real step script, heartbeat builder, and update-command-status CLI against a controlled queue and recording gh. A current owner writes Waiting; a superseded step fence, an owner lost before or during comment lookup, and a queue error all make zero status writes. Docs (scheduler maintainer contract) and a changelog fragment updated.
Summary
Reviews that fail because the model provider is temporarily out of capacity are recorded as permanent failures instead of being retried.
On 2026-10-13 between 12:00 and 14:00 UTC, failed exact reviews spiked to 11 and 10 per hour. In the five failure diagnostics I sampled, four carried the same provider error, across openclaw-enterprise, acpx and wacli:
Their diagnostics manifests all read
"classification": "codex_execution","retryable": false,"reason_code": "unknown"(for example https://github.com/openclaw/clawsweeper/actions/runs/38409514528). The capacity matchers only knew rate-limit, TPM, 429, "temporarily unavailable", "overloaded" and "please try again in …" wording, so this message fell through tocodex execution failed.Change
src/codex-transient.tsdefines the provider capacity pattern once (CODEX_PROVIDER_CAPACITY_ERROR) and adds the full provider diagnosticselected model is at capacity. A bareat capacitywould be unsafe: failed-review retry eligibility scans report text that includes the item title, so an item titled "Service is at capacity" with a permanent failure would become retryable (ClawSweeper's P2 finding on the first head, also raised in fix(review): retry Codex model-capacity failures as provider throttling #1969 (comment)).isRetryableCodexTransportErroruses it, so the error is retryable forCodexReviewError.retryable, record retry eligibility, and runCodex's in-process capacity retries.failedReviewFailureDetailinsrc/clawsweeper-record-metadata.tsno longer scans the item title. Its raw-text fallback (first 8,000 report characters) drops thetitleandfixed_pr_titlefront-matter lines and the# [#N: title](url)heading, so contributor-written titles cannot make a permanent failure look like a retryable provider error. This resolves ClawSweeper's second P2 (fix(review): retry Codex model-capacity failures as provider throttling #1969 (comment)): even the full diagnostic used as a title was matched. Failure evidence such asreview_failure_reason, the decision summary and the Summary/Evidence sections is still scanned.codexFailureReasoninsrc/clawsweeper-review-runtime.tsreuses the same pattern instead of its own inline copy, so the failure log kind isprovider_throttle. The inline copy also picks up the decimalplease try again in 1.5sform the shared list already had.Behavior proof
node dist/clawsweeper.js retry-failed-reviews --target-repo openclaw/openclaw --items-dir <tmp> --item-number 4242 --max-attempts 2 --cooldown-minutes 45, with a mockgh(GH_BIN) that answers the item, PR head and workflow default-branch reads and records therepos/openclaw/clawsweeper/dispatchesPOST. The proof script lives under the ignored.artifacts/directory.mainrecorded failures on 2026-10-13: summaryCodex review failed: codex execution failed., detail containingERROR: Selected model is at capacity. Please try a different model.; (2) the title trap: titleSelected model is at capacityin both front matter and heading, permanentCodex execution failed.main(44696e44b3)skipped_non_infrastructure_failure878d26ca)dispatched_failed_review_retry(retryable codex transport failure (capacity))mainskipped_non_infrastructure_failure9850d3badispatched_failed_review_retry878d26ca)skipped_non_infrastructure_failureThe real
runCodexpath is covered too:test/codex-review-runner.test.tsdrives a fakecodexbinary that fails with the production text; it is handed to the durable queue as a retryable capacity failure with this change and not onmain.ghstands in for GitHub; no live provider capacity event was triggered. The durable queue's backoff for retryable provider failures is unchanged.Validation
test/repair/codex-transient.test.ts: the production text is retryable, not terminal, and not a context-limit error. Negative cases keep ClawSweeper's own "required filesystem capacity is unavailable" error and a bare "Service is at capacity" non-retryable at the matcher level.test/failed-review-retry.test.ts: report-level regression. The provider diagnostic yieldsplanned_failed_review_retry; titlesSelected model is at capacityandService is at capacityin front matter and heading, with a permanent failure, yieldskipped_non_infrastructure_failure.test/codex-review-runner.test.ts: the same text is classifiedprovider_throttle, plus the runner row above. The new provider-diagnostic cases fail onmain's source and pass here; the three suites total 94/94.pnpm run check:static,pnpm run lint,build:allandgit diff --checkpass./review(autoreview, P0–P2) is clean on the original change, the committed branch, the narrowed matcher, and the title exclusion.OpenClaw Bay
Not affected. The failure taxonomy already includes
provider_throttle; no status, lifecycle or projection contract changes.