Repository navigation
refactor(agents): absorb overflow, retry, and matcher duplicates into the failover substrate - #121817
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 12:57 AM ET / 04:57 UTC. ClawSweeper reviewWhat this changesThis PR centralizes provider-error classification, retry evidence, API-key rotation, and compaction status parsing in the agents failover subsystem. Merge readinessKeep open for maintainer approval: no source-level blocker was found, but this intentionally changes shared retry and classification semantics and exact-head CI is still running. Priority: P2 Review scores
Verification
How this fits togetherProvider errors enter the agents failover classifier, whose facts drive retries, fallback decisions, API-key rotation, and compaction diagnostics. The refactor removes separate matchers so these consumers interpret errors consistently. flowchart LR
A[Provider error] --> B[Failover classification]
B --> C[Retry evidence]
B --> D[API key rotation]
B --> E[Compaction diagnostics]
C --> F[Retry or fallback decision]
Decision needed
Why: This is an intentional semantic consolidation across several established consumers, so source review cannot decide whether every listed behavior change is the desired long-term compatibility contract. Before merge
Agent review detailsSecurityNone. PR surfaceSource +638, Tests +121, Generated 0. Total +759 across 29 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical failover substrate, with maintainers approving the documented classification ledger after the exact-head agent-runtime and QA checks pass. Do we have a high-confidence way to reproduce the issue? Unclear for an independently executed run: source exposes focused classifier and retry cases, but this read-only environment did not run the contributor’s suite. Is this the best way to solve the issue? Yes: centralizing duplicated decision policy in failover is the strongest owner boundary, provided maintainers accept the intentionally changed classifier rows. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 45ec5f4662f2. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
3b60a74 to
afbb386
Compare
09c155d to
0b7c8b0
Compare
0b7c8b0 to
037c0a7
Compare
|
Merged via squash.
|
… the failover substrate (openclaw#121817) * refactor(ai): centralize context overflow matching * refactor(agents): add retry evidence and guarded status facets * refactor(agents): absorb assistant retry and key matchers * chore(plugin-sdk): refresh failover closure hashes * fix(agents): consume retry evidence at altitude zero * test(agents): narrow retry corpus provider fixtures * test(agents): keep retry corpus sorting immutable
What Problem This Solves
OpenClaw still had three independent provider-error classifier stacks outside the failover substrate: context overflow patterns in both
@openclaw/aiand core, a retry-local transient/error deny-list, and numeric substring matchers for live key rotation and compaction diagnostics. Their decisions could drift, and bare numbers such as429inside request IDs, model names, or token counts could trigger key rotation or provider-error telemetry.Why This Change Was Made
This change makes
@openclaw/aithe scoped canonical overflow-pattern owner, adds a distinct transient-retry-evidence facet to the failover substrate, and routes altitude-0 retry, live API-key rotation, and compaction status parsing through canonical facts. Classification remains broader than same-attempt retryability: retries still require positive transient evidence, and the checked-in corpus oracle freezes every old retry decision.Provider-specific overflow wording can continue migrating from the package fallback scope into provider plugin hooks in later focused work; this PR preserves the existing lazy provider-runtime gate.
The branch was kept as one PR because the full review surface is 1,509 changed lines, below the 2.5k split valve.
AI-assisted: Codex.
User Impact
Operators keep the same retry/backoff behavior across the original 570-row corpus while gaining consistent overflow and rate-limit classification. API keys no longer rotate for embedded numeric substrings or account-wide billing exhaustion, and compaction diagnostics only treat guarded HTTP statuses as provider 4xx/5xx errors.
@openclaw/aikeeps the existingisContextOverflow(message, contextWindow?)signature and behavior. The new message-scope matcher is additive on the existing internal runtime subpath.Evidence
Classification and flip ledger:
input length 14295 tokens exceeds the model limitnow classifies ascontext_overflow; PR 2 removed its accidental embedded-429 rate-limit result, and the canonical overflow scope now owns the actual wording.ResourceExhaustedand spacedresource exhaustedclassify asrate_limit.quota_exceededclassifies asrate_limit.GoUsageLimitError,FreeUsageLimitError,available balance, andout of budgetclassify asbilling.req-4291, model names containing0429, overflow token counts containing429, and429 insufficient_quota; intended rate-limit strings still rotate.{400,401,403,429}and{500,502,503,504}. Embedded token/model/request numbers now remainunknown, while guarded leading, wrapped, and labeled provider statuses retain their existing buckets.Production LOC: +277/-295 (net -18)
Tests/test support: +840/-63
Generated Plugin SDK closure metadata: +17/-17; declarations are unchanged.
Focused and boundary proof:
node scripts/run-vitest.mjs src/agents/failover— 17 files, 2,138 tests passed.node scripts/run-vitest.mjs packages/ai— 69 files, 1,342 tests passed.node scripts/run-vitest.mjs src/llm— 21 files, 784 tests passed.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run— 384 files, 4,724 tests passed.src/agents/embedded-agent-runner.run-embedded-agent.fault-sequences.e2e.test.ts— 5 ordered scenarios passed.src/agents/sessions/sdk.test.ts— 30 tests passed.src/agents/sessionsexposed the unchanged macOS Unicode-equivalent filename test failure; the same failure reproduces at exact launch basea7564ee12f159394fa3b28b9ae7390de83e1953e. The touched session retry boundary is green above.pnpm buildpassed; noINEFFECTIVE_DYNAMIC_IMPORTwarning, and built plugin control-plane loads passed.pnpm check:import-cyclespassed with 0 runtime value cycles.node scripts/check-changed.mjspassed via the documented trusted-source local fallback after all configured remote providers failed readiness. This covered formatting, SDK contract, dead exports, production/test typecheck, core lint, cycles, and architecture guards.pnpm format <touched>andgit diff --checkpassed.Inherited red-main repair: launch-base
f09a33ce412addedattachModelProviderRuntimePluginHandleto attempt dispatch, but the shared embedded-runner E2E mock omitted the export. The smallest test-only mock repair is included so the requested fault-sequence proof runs again.