Repository navigation
refactor(agents): consolidate failover classification into one substrate - #121341
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
ced60a0 to
9a4f3e5
Compare
|
Codex review: found issues before merge. Reviewed August 9, 2026, 10:46 PM ET / August 10, 2026, 02:46 UTC. ClawSweeper reviewWhat this changesThis PR moves agent failover classification into a shared subsystem and redirects fallback, retry, gateway, cron, and provider consumers to the consolidated classifier. Merge readinessKeep open: the proposed refactor removes the current cheap context-candidate gate before provider-hook dispatch, so ordinary error classification can resolve provider runtime unnecessarily. The branch is also currently dirty against main and needs a corrected rebase plus exact-head validation. Priority: P2 Review scores
Verification
How this fits togetherProvider and runtime errors are converted into stable failover reasons that drive model fallback, retry decisions, gateway responses, and user-facing recovery text. Provider plugins can refine those reasons before shared rules select the final outcome. flowchart LR
A[Provider or runtime error] --> B[Failover signal]
B --> C[Context candidate check]
C --> D[Provider plugin classification]
C --> E[Shared error tables]
D --> F[Stable failover reason]
E --> F
F --> G[Fallback retry and user error output]
Decision needed
Why: The PR changes a shared provider-runtime hot path and currently has merge conflicts; protected maintainer work requires an explicit human merge decision after the mechanical correction. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep provider-hook consultation behind the existing cheap context-shape gate, retain table classification for ordinary errors, and add a regression test proving generic non-context errors do not invoke provider hooks. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main gates provider-hook dispatch on context-shaped text, while the supplied patch invokes it before table checks; a focused spy test can demonstrate the changed call behavior. Is this the best way to solve the issue? No: consolidation is reasonable, but the best fix retains the existing lazy candidate boundary before invoking provider hooks rather than making all error paths consult them. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ca6a3797452b. 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
|
d8b067d to
fb037cc
Compare
fb037cc to
364a9f7
Compare
|
Merged via squash.
|
Upstream openclaw#121341 removed embedded-agent-helpers/types.ts; FailoverReason now lives in failover/signal.ts. Also un-export two module-internal symbols flagged by knip (ModelCircuitGateResult, laterFallbackCandidateCanReachTransport). Local gates on this head: build:plugin-sdk:dts, tsgo:core, tsgo:core:test, tsgo:extensions, extension package boundary, deadcode:full, check:max-lines-ratchet, oxlint, oxfmt - all clean; 425 tests passed (model-fallback, circuit, failover-error suites).
…ate (openclaw#121341) * refactor(agents): consolidate failover classification substrate * chore(agents): align failover refactor guards * fix(agents): preserve leading 429 status handling * perf(agents): retain lazy failover hook gating * chore(agents): refresh failover guard artifacts
What Problem This Solves
Failover classification was spread across the oversized embedded-agent error grab-bag, three separate matcher modules, and two mutually exclusive provider-hook paths. That made precedence drift easy: structured and message-only failures did not consult plugins consistently, status-like numbers matched inside unrelated identifiers, and the same provider wording could land in timeout, overload, or server-error lanes.
This change creates one canonical failover substrate under
src/agents/failover/, gives the frozen 16 reason codes a readonly tuple for later schema derivation, and makes one provider-plugin consultation with the fullest available signal precede legacy provider fallbacks and generic tables.Why This Change Was Made
The classifier now owns the shared tables and precedence while concept-specific residue moved into small modules for assistant-message failures, runtime diagnostics, error text, image parsing, context observations, and signal extraction. The old
errors.ts,failover-matches.ts,provider-error-patterns.ts,context-overflow.ts, and failover type path are removed rather than retained as shims.The golden corpus moved with the classifier and was expanded with 189 distinct real strings recovered from the deleted matcher suites. It now covers 570 unique central-classification rows, while predicate-specific differences remain in focused tests.
User Impact
Approved classification changes:
input length 14295 tokens exceeds the model limit:rate_limit→ unclassified. PR 6 will reclaim this wording in the canonical overflow table.req-4291:rate_limit→ unclassified because429is no longer accepted inside identifiers.model gpt-5.5-preview-0429 not found:rate_limit→model_not_found.model model-x-500-preview not found: unclassified →model_not_found.400 Model Id [gpt-5.4-nano] not found: unclassified →model_not_found.503 Service Unavailable, Mistral temporary-unavailable text, generic LLM service-unavailable text, API-error service-unavailable JSON, billing/subscription service failures, and Retry-After service-unavailable text:timeout→overloaded(seven frozen corpus rows).concurrency limit breachedandconcurrency limit was reached: unclassified →rate_limit.insufficient credits: billing predicatefalse→true; the 512-character cliff is gone while explanatory multi-section Markdown remains excluded.ThrottlingExceptionis now owned only by the generic word-bounded throttling rule; the legacy provider-specific result changesrate_limit→null. Central classification remainsrate_limit.throttling disabled for this accountremainsrate_limitby the accepted generic-rule tradeoff.Evidence
node scripts/run-vitest.mjs src/agents/failover: 16 files, 2,039 tests passed on the final head.node scripts/run-vitest.mjs src/agents/embedded-agent-helpers: 15 files, 114 tests passed.node scripts/run-vitest.mjs src/plugins/provider-runtime.test.ts: 66 tests passed.pnpm build: passed in 5m22s; no[INEFFECTIVE_DYNAMIC_IMPORT]warning.pnpm check:import-cycles: 0 runtime value cycles.pnpm check:test-types: passed.pnpm check:max-lines-ratchet: passed after pruning the two deleted oversized files.pnpm plugin-sdk:api:check: passed with the regenerated manifest.pnpm deadcode:dependenciesandpnpm deadcode:exports: passed with zero unused exports.git diff --check: passed.The requested broad
src/agentssweep was attempted, but the shared host collapsed into unrelated 120-second timeouts across MCP, message-tool, cron, CLI, subagent, and hook suites while the heavy-check lock rotated among other worktrees. The two failover-adjacent failures from that run passed when isolated.node scripts/check-changed.mjsalso attempted its required remote route, but every configured backend failed readiness; exact-head PR CI is the authoritative full type/lint fan-out.