Repository navigation
fix: resume after settled-tool context overflow - #128970
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 11:22 PM ET / August 25, 2026, 03:22 UTC. ClawSweeper reviewWhat this changesThe PR lets a fully settled, replay-unsafe tool turn compact its current embedded-agent transcript after a mid-turn context overflow, then continue without rerunning the tool. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessNo actionable correctness or security finding found. This remains open for explicit maintainer handling because it is maintainer-authored and carries the protected Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherThe embedded-agent runner invokes models and tools while retaining an attempt transcript. Its overflow recovery compacts the active session and retries from the compacted transcript, or returns an actionable recovery message when safe continuation cannot be established. flowchart LR
A[Tool result settles] --> B[Mid-turn context precheck]
B --> C{Context overflow}
C --> D[Verify settled tool batch]
D --> E[Compact active transcript]
E --> F[Continue from transcript]
C --> G[Actionable recovery message]
Decision needed
Why: The protected maintainer label and maintainer authorship require an explicit human landing decision even though the reviewed patch has no discrete defect. Before merge
Agent review detailsSecurityNone. PR surfaceSource +145, Tests +84. Total +229 across 5 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one generic current-transcript compaction path that never replays settled tools, with session-identity validation before continuation. Do we have a high-confidence way to reproduce the issue? Yes: current main's replay-unsafe early return prevents the existing overflow recovery owner from running, and the PR's full-runner regression models the exact settled-tool precheck path. Is this the best way to solve the issue? Yes: it reuses the existing compaction owner and exact settled-batch evidence instead of adding a replay or parallel recovery path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0022cd254204. 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
History |
Co-authored-by: VACInc <[email protected]>
Co-authored-by: VACInc <[email protected]>
5edbc35 to
944e3ab
Compare
|
@clawsweeper re-review Exact-head evidence completed after the prior review snapshot:
The previous review reported no actionable code or security findings; this rerun is to refresh the evidence verdict against the completed gates. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
… advance 80) Resolution (13 raw conflicts; 12 ui resolved by fork-ownership policy): - pnpm-lock.yaml: regenerated via pnpm install (derived file). - extensions/openshell/src/openshell-core.test.ts (merge=ours drift): ADOPT-UPSTREAM openclaw#129258 fixture dedup + openclaw#120996 tempWorkspace migration + openclaw#126828 canonical-owner test (fork's makeTempDir shape + missing test were stale freezes of older upstream code, not fork intent). Grafted fork's one genuine delta: required SandboxConfig.osSandbox block into createOpenShellBackendSandboxConfig. - src/agents/cli-runner.reliability.test.ts (merge=ours drift): clean 3-way merge-file. Kept fork tests + upstream openclaw#125085 (codex->agent-cli literals, watchdog resume tuning test; math verified against merged reliability.ts). - src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts: ADOPT-UPSTREAM (preflight tsgo-core=1 catch: upstream consumer openclaw#128970 imports resolveSettledToolBatchEvidence which merge churn had dropped from the fork provider; export surface differs by exactly this extraction; fork toolMetas type carries toolCallId?/terminate?/isError?). - ui/src/ui/markdown.ts: explicit param types on the linkify www plugin callbacks (validate/normalize). @types/markdown-it 14.1.2->14.2.0 (upstream dep bump) dropped contextual typing for them; the fork-owned ui copy now types them inline per linkify-it's Validate/Match signatures (upstream adapted its own ui tree the same way). Only ui file needed it; tsgo:test:ui 3->0 locally. Note: ui tree-hash invariant vs main intentionally broken by this one adaptation — main's ui does not compile against the new lockfile (baseline 0 was measured with @types 14.1.2). No product-collision: no codex/** residuals.
* fix(agents): compact settled mid-turn tool overflow * test(agents): provide overflow replay metadata Co-authored-by: VACInc <[email protected]> --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: VACInc <[email protected]>
…pending (#129792) * fix(agents): compact mid-turn overflow while code-mode work is still pending #128970 let a mid-turn overflow compact and continue only when every lifecycle item was balanced. A code-mode exec that returns status "waiting" has its result persisted, but its nested tool keeps a lifecycle item active, so the gate failed closed: no compaction, a generic "couldn't generate a response" warning, and the waiting run expired before the operator could resume it. Continuation resumes from the persisted tool results and never replays the assistant call, so the transcript is the settlement proof: gate on every requested tool call having a recorded result. Nested code-mode work stays owned by the run registry and resumes through `wait`, exactly as across turns. * fix(agents): keep parked code-mode work fail-closed across a rotated compaction A parked code-mode run is bound to the session it started in and `wait` rejects any other session, so a compaction that adopts a successor session cannot redeem it. When nested tool work is still parked, treat a rotating mid-turn compaction as a failed recovery and surface overflow guidance instead of a continuation that would fail on that binding. * fix(agents): keep post-compaction hooks when a rotated retry is withheld Withholding the mid-turn continuation after a rotating compaction must not turn the committed compaction into a failure: maintenance, the after hook, the compaction count, and the post-compaction guard still run. Only the retry and the tool-result truncation retry are skipped before surfacing the overflow guidance. * fix(agents): admit active-item continuation only for Code Mode runs Generic tools keep the fully-settled predicate; only a run with Code Mode engaged may continue while lifecycle items are active, since that is the one case where the outer exec result is persisted while the parked nested call stays owned by the code-mode run registry. A generic tool with an active item stays fail-closed (new regression). * fix(agents): gate active-item continuation on a recorded Code Mode suspension codeModeEngaged only says Code Mode controls were enabled for the attempt; Code Mode can still run direct tools, so a recorded direct-tool result plus unrelated active lifecycle work could take the weaker branch with no parked exec to resume. Record the fact where it happens instead: the tool completion handler marks an exec result that came back "waiting" as codeModeSuspended, and recovery continues past active items only when the recorded batch carries that fact. Code Mode enabled with a direct tool active stays fail-closed. * fix(agents): mark a parked run only for the marked Code Mode exec tool isExecToolName matches any tool named exec or bash, but only the marked Code Mode exec owns a resumable run. Carry the marked control-tool identity from the run's tool list (where the tool objects are known) to the subscription as codeModeExecToolNames, and record codeModeSuspended only for those tools. A plain exec returning a waiting-shaped result is no longer marked. * fix(agents): collect the Code Mode exec identity from the registered tool surface uncompactedEffectiveTools is the bundle list before the tool catalog creates the marked Code Mode controls, so the identity set was empty in real Code Mode runs and the parked-run fact was never recorded. Derive it from the post-catalog effectiveTools, where the activity wrapper preserves the marker through copyAgentToolMetadata. * fix(agents): block rotated retries for every recorded parked Code Mode run A local yield_control parks the marked exec without creating a nested lifecycle item, so gating the rotation block on activeCount let that case retry in the successor session where wait rejects the original binding. Key the block off the recorded codeModeSuspended fact instead, with a zero-active-item rotation regression. --------- Co-authored-by: VACInc <[email protected]>
…pending (openclaw#129792) * fix(agents): compact mid-turn overflow while code-mode work is still pending openclaw#128970 let a mid-turn overflow compact and continue only when every lifecycle item was balanced. A code-mode exec that returns status "waiting" has its result persisted, but its nested tool keeps a lifecycle item active, so the gate failed closed: no compaction, a generic "couldn't generate a response" warning, and the waiting run expired before the operator could resume it. Continuation resumes from the persisted tool results and never replays the assistant call, so the transcript is the settlement proof: gate on every requested tool call having a recorded result. Nested code-mode work stays owned by the run registry and resumes through `wait`, exactly as across turns. * fix(agents): keep parked code-mode work fail-closed across a rotated compaction A parked code-mode run is bound to the session it started in and `wait` rejects any other session, so a compaction that adopts a successor session cannot redeem it. When nested tool work is still parked, treat a rotating mid-turn compaction as a failed recovery and surface overflow guidance instead of a continuation that would fail on that binding. * fix(agents): keep post-compaction hooks when a rotated retry is withheld Withholding the mid-turn continuation after a rotating compaction must not turn the committed compaction into a failure: maintenance, the after hook, the compaction count, and the post-compaction guard still run. Only the retry and the tool-result truncation retry are skipped before surfacing the overflow guidance. * fix(agents): admit active-item continuation only for Code Mode runs Generic tools keep the fully-settled predicate; only a run with Code Mode engaged may continue while lifecycle items are active, since that is the one case where the outer exec result is persisted while the parked nested call stays owned by the code-mode run registry. A generic tool with an active item stays fail-closed (new regression). * fix(agents): gate active-item continuation on a recorded Code Mode suspension codeModeEngaged only says Code Mode controls were enabled for the attempt; Code Mode can still run direct tools, so a recorded direct-tool result plus unrelated active lifecycle work could take the weaker branch with no parked exec to resume. Record the fact where it happens instead: the tool completion handler marks an exec result that came back "waiting" as codeModeSuspended, and recovery continues past active items only when the recorded batch carries that fact. Code Mode enabled with a direct tool active stays fail-closed. * fix(agents): mark a parked run only for the marked Code Mode exec tool isExecToolName matches any tool named exec or bash, but only the marked Code Mode exec owns a resumable run. Carry the marked control-tool identity from the run's tool list (where the tool objects are known) to the subscription as codeModeExecToolNames, and record codeModeSuspended only for those tools. A plain exec returning a waiting-shaped result is no longer marked. * fix(agents): collect the Code Mode exec identity from the registered tool surface uncompactedEffectiveTools is the bundle list before the tool catalog creates the marked Code Mode controls, so the identity set was empty in real Code Mode runs and the parked-run fact was never recorded. Derive it from the post-catalog effectiveTools, where the activity wrapper preserves the marker through copyAgentToolMetadata. * fix(agents): block rotated retries for every recorded parked Code Mode run A local yield_control parks the marked exec without creating a nested lifecycle item, so gating the rotation block on activeCount let that case retry in the successor session where wait rejects the original binding. Key the block off the recorded codeModeSuspended fact instead, with a zero-active-item rotation regression. --------- Co-authored-by: VACInc <[email protected]>
Closes #128963
What Problem This Solves
Fixes an issue where long-running embedded-agent sessions could stop with a generic incomplete-turn warning when a settled replay-unsafe tool pushed the next continuation over the model context budget. Automatic compaction was detected but skipped, leaving the session blocked until an operator manually reset or compacted it.
Why This Change Was Made
This separates permission to replay the original attempt from permission to compact and continue from exact, settled current-transcript evidence. A mid-turn overflow may now continue after compaction only when every tool is proven settled, there is no asynchronous activity, and the same session still owns the compaction target. Unsettled, asynchronous, stale, or ownership-changed states remain fail-closed, and exhausted recovery preserves actionable context-overflow guidance with an appropriate side-effect caution.
User Impact
Agents can compact and finish their response after a settled tool call crosses the context threshold without executing that tool again. If safe continuation cannot be proven, users receive a context-overflow recovery action rather than an unrelated generic incomplete-turn warning.
Evidence
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.shared-integration.test.ts— 71/71 passed.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/overflow-context-recovery.test.ts src/agents/embedded-agent-runner/run/attempt-recovery.test.ts src/agents/embedded-agent-runner/run/settled-tool-evidence.test.ts— 41/41 passed.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.shared-integration.test.ts— 25/25 in the failed shard passed after supplying production-required replay metadata.pnpm tsgo:core— passed.pnpm tsgo:core:test— passed.node scripts/check-changed.mjs -- src/agents/embedded-agent-runner/run/attempt-recovery.ts src/agents/embedded-agent-runner/run/overflow-context-recovery.ts src/agents/embedded-agent-runner/run/overflow-context-recovery.test.ts src/agents/embedded-agent-runner/run.midturn-precheck-retry.test-support.ts— passed..agents/skills/autoreview/scripts/autoreview --mode uncommitted— clean; no actionable findings.944e3abad0d— 185 successful, 42 skipped, 1 neutral, 0 failed or pending.run_7bbe58dfae0b— real embedded runner selectedroute=compact_onlyat 1,004 tokens over budget withtoolResultReducibleChars=0; rawexecran exactly once, auto-compaction succeeded once, the continuation issued a third provider request, and the final response marker was visible. Lease released after proof.codex-rs/core/src/session/turn.rs,compact.rs, andcompact_remote.rs; completed tool handling precedes compaction and continuation from installed history.