Repository navigation
refactor(agents): simplify failure recovery bookkeeping - #139362
Conversation
Consolidate repeated classification, decision inputs, retry/log payloads and compaction dispatch while preserving retry policy and failure-mark ordering. Follow-up to #139295.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 4:39 PM ET / 20:39 UTC. ClawSweeper reviewWhat this changesSimplifies agent failure classification, retry bookkeeping, decision types, and compaction dispatch while preserving existing recovery behavior. Merge readiness✅ Ready for maintainer review Keep open: this is a coherent, maintainer-protected cleanup that remains distinct from the merged thinking-recovery fix. Source review found no blocking correctness defects. Priority: P3 Review scores
Verification
How this fits togetherThe embedded agent runner handles failed model attempts and chooses retries, account rotation, model fallback, or a visible error. Its compaction path summarizes session history under existing timeout and cancellation controls. flowchart TD
A[Model attempt] --> B[Failure classification]
B --> C[Recovery policy]
C --> D[Retry or account rotation]
C --> E[Model fallback or visible error]
D --> A
F[Session history] --> G[Compaction with timeout controls]
G --> A
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -121, Tests -12. Total -133 across 8 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep recovery bookkeeping consolidated within its existing owners while retaining distinct prompt, assistant, and compaction policies. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes behavior-preserving cleanup rather than a new bug fix; review checked source equivalence and retained regression assertions without executing tests. Is this the best way to solve the issue? Yes: local consolidation removes repeated bookkeeping without merging intentionally different recovery policies or introducing another abstraction layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9c068e13bd18. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Ready to land at This cleanup removes 121 production lines and 12 unused test-fixture arguments, with assertions retained. Prompt/assistant policy differences, provider-owner classification, cancellation/timeout guards, warning text, retry counters, and rotation-before-mark ordering remain intact. Validation:
Focused test command: OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/tmp/recovery-deslop-vitest-cache \
node scripts/run-vitest.mjs \
src/agents/failover-policy.test.ts \
src/agents/embedded-agent-helpers/thinking.test.ts \
src/agents/embedded-agent-runner/run/failover-policy.test.ts \
src/agents/embedded-agent-runner/run/prompt-failure.test.ts \
src/agents/embedded-agent-runner/run/assistant-failover.test.ts \
src/agents/embedded-agent-runner/run/assistant-failure.test.ts \
src/agents/embedded-agent-runner/run/attempt-recovery.test.ts \
src/agents/embedded-agent-runner/compact.hooks.test.tsNo public API, configuration, schema, dependency, or intended runtime behavior changes. |
|
Merged via squash.
|
) Consolidate repeated classification, decision inputs, retry/log payloads and compaction dispatch while preserving retry policy and failure-mark ordering. Follow-up to openclaw#139295.
Related: #139295
Additional instructions
Maintainers can edit this branch.
What Problem This Solves
Failure recovery carried duplicate error classification, policy argument construction, retry result construction, and logging payloads. That repetition obscured the ordering that keeps retries responsive while failed-account bookkeeping settles. This is the requested deeper cleanup following #139295.
Why This Change Was Made
Prompt recovery now reuses its classified failure and one policy resolver, and starts failure marking through one path while preserving the existing await/nonblocking split. Assistant recovery shares retry outcomes and counter logging. Decision unions express their actual shapes directly; dead abort plumbing, duplicate conditions, conditional type extraction, and repeated cooldown eligibility are removed. Automatic compaction has one equivalent dispatch path, with its existing default policy and cancellation behavior preserved.
The separate prompt/assistant timeout rules, prepared provider-owner classification distinction, and lifecycle/cleanup guards remain intact. Failure containment stays with its current callers so warning text and timing remain stable.
User Impact
Behavior-preserving cleanup. Retry budgets, account/model fallback, error messages, logging, failure-marking order, and compaction policies remain unchanged. No config, persistence schema, dependency, protocol, or public API changes.
Production: 121 fewer lines across seven modules. Tests: 12 unused fixture-argument lines removed; assertions and coverage retained.
Evidence
git diff --checkpass.