fix(agents): recover claude-cli context-overflow sessions and keep retry artifacts alive#98934
Merged
Conversation
Contributor
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(agents): recover claude-cli context-overflow sessions and keep retry artifacts alive This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
This was referenced Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #98897
What Problem This Solves
Two claude-cli session-recovery defects found by a reliability audit:
context_overflowclassification that mapped to failover reasonunknownwith no retry code, so the existing fresh-session reseed machinery never fired and nothing on the main auto-reply path cleared the stale binding. Every subsequent turn resumed the same overflowing session and failed identically until a manual/reset. Since claude-cli setsownsNativeCompaction: true, OpenClaw pre-turn compaction is a no-op for it — this path had no recovery at all. Same failure class as FailoverError during cli-backend turn does not clear stale cliSessionIds from sessions.json, causing infinite retry loop #97887.mcp.jsonand skills-plugin dirs, then the fresh-session recovery retry re-ran on the same context whose argv still pointed at the deleted paths — the recovery spawn failed, defeating the retry.Why This Change Was Made
context_overflowis now a first-class failover reason across the closed reason unions (agent runtime, cron run-log, gateway protocol schema — additive enum extension, HTTP status 413, OpenAI-compatinvalid_request_error). CLI context-overflow failures carry acli_context_overflowretry code on both the live and one-shot paths, flow throughshouldRetryFreshCliSessionAfterFailover, clear the stale binding, and take the existing fresh-session reseed retry so context is carried forward instead of dropped.User Impact
Long-running claude-cli sessions that hit a context overflow now recover automatically with a fresh reseeded session instead of failing every turn until a manual
/reset. Recovery retries after no-output timeouts work in non-capture configurations instead of spawning against deleted config paths.Evidence
node scripts/run-vitest.mjsacross cli-runner reliability/spawn/session, failover-error, cron run-log, and protocol conformance tests (400 tests pass); full remotepnpm check:changedgreen on Blacksmith Testboxtbx_01kwgm9tmtgyw8rzwh48exqer7(https://github.com/openclaw/openclaw/actions/runs/28567342178, exit 0); repo autoreview (branch mode) clean.