Repository navigation
fix(agents): prevent early recovery aborts of foreground exec - #148959
Conversation
|
🦞👀 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 15, 2026, 6:29 AM ET / 10:29 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR passes accepted process deadlines to session recovery so long foreground commands can finish or return timeout results without prematurely aborting the agent turn. Merge readiness✅ Ready for maintainer review Keep open: this remains a useful fix for premature whole-turn aborts on current main. No actionable introduced defect was found, and the prior draft-status blocker is resolved. Priority: P1 Review scores
Verification
How this fits togetherThe exec tool runs agent-requested commands through the process supervisor. Session recovery watches tool activity and decides when to terminate stalled turns; this change lets it respect the supervisor’s accepted deadline. flowchart TD
A[Agent command] --> B[Exec preparation]
B --> C[Process supervisor]
C --> D[Accepted deadline]
D --> E[Session recovery check]
E --> F[Keep active command running]
E --> G[Recover overdue stalled turn]
C --> H[Command result or timeout error]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +133, Tests +410. Total +543 across 12 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. Technical reviewBest possible solution: Keep command expiry owned by the supervisor and let shared recovery respect its deadline while preserving timeout results, explicit cancellation, and bounded hang recovery. Do we have a high-confidence way to reproduce the issue? Yes: a foreground command lasting beyond the 15-minute recovery floor with a longer process timeout follows the source-proven failure path. The supplied baseline run corroborates it; this review did not execute current main. Is this the best way to solve the issue? Yes: projecting the supervisor’s accepted deadline into the existing recovery owner fixes the competing timeout decisions without adding configuration or another process timer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2b8c9f1ad64a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
landpr-approve-admin-merge |
|
landpr-approve-unrelated-red |
|
Thanks @vicvinc for the reports and @alvinveroy for the trace! Proof: A 970-second foreground command with a 1,400-second timeout completed and returned its tool result and final answer. Short expiry returned a tool error and continued; a command without a deadline was still recovered.
|
* commit 'ba441dd2d14e1d02dca72dd341cff28c360acaa2': fix(ci): remove duplicate Copilot auth metadata (#149016) test(agents): align auth fixtures with runtime store reads (#149004) improve: reduce data fetched during reminder maintenance (#148996) fix(cron): skip availability checks when session pruning is idle (#148920) fix(auth): guard GitHub Copilot device flow authority (#148999) fix(agents): prevent early recovery aborts of foreground exec (#148959) fix(github-copilot): remove retired Raptor mini (#116505) improve(feishu): reduce preparation work for documents with tables (#148997) improve: reduce database work when recording participants (#148841) test: accept Bun error labels in plugin assertions (#148955) fix(models): clarify saved account health and catalog status (#148987)
* commit '1226eecf4ff909de172a6837422cfa64723fade8': (39 commits) test: align model auth and setup fixtures with current behavior (#149023) refactor: reuse web search request context (#148949) fix(ci): remove duplicate Copilot auth metadata (#149016) test(agents): align auth fixtures with runtime store reads (#149004) improve: reduce data fetched during reminder maintenance (#148996) fix(cron): skip availability checks when session pruning is idle (#148920) fix(auth): guard GitHub Copilot device flow authority (#148999) fix(agents): prevent early recovery aborts of foreground exec (#148959) fix(github-copilot): remove retired Raptor mini (#116505) improve(feishu): reduce preparation work for documents with tables (#148997) improve: reduce database work when recording participants (#148841) test: accept Bun error labels in plugin assertions (#148955) fix(models): clarify saved account health and catalog status (#148987) test(plugins): align Copilot auth-choice registry expectations (#148981) fix(channels): reject blank integer channel add options (#145534) fix(ui): preserve archive undo after chat navigation (#148831) feat: show cited source previews in macOS and iOS chat (#148906) fix: avoid redundant tab updates while chats stream (#148865) test(qa): run Discord through Crabline (#116446) perf(crabbox): prepare project runtimes during worker download (#148952) ...
* commit '84114b5a2711764e2ca333e327e808fd88316063': (40 commits) improve(sessions): reuse compiled transcript metadata queries (#148773) fix(ci): repair Copilot contracts and config failure diagnostics (#149001) test: align model auth and setup fixtures with current behavior (#149023) refactor: reuse web search request context (#148949) fix(ci): remove duplicate Copilot auth metadata (#149016) test(agents): align auth fixtures with runtime store reads (#149004) improve: reduce data fetched during reminder maintenance (#148996) fix(cron): skip availability checks when session pruning is idle (#148920) fix(auth): guard GitHub Copilot device flow authority (#148999) fix(agents): prevent early recovery aborts of foreground exec (#148959) fix(github-copilot): remove retired Raptor mini (#116505) improve(feishu): reduce preparation work for documents with tables (#148997) improve: reduce database work when recording participants (#148841) test: accept Bun error labels in plugin assertions (#148955) fix(models): clarify saved account health and catalog status (#148987) test(plugins): align Copilot auth-choice registry expectations (#148981) fix(channels): reject blank integer channel add options (#145534) fix(ui): preserve archive undo after chat navigation (#148831) feat: show cited source previews in macOS and iOS chat (#148906) fix: avoid redundant tab updates while chats stream (#148865) ...
## What Problem This Solves Silent configured MCP calls were aborted after about six minutes, before their results arrived. Closes #140671. ## Why This Change Was Made Bundle assembly attaches the existing lifecycle wrapper before direct or catalog exposure. Both paths share one attempt context; this state has one writer. The wrapper emits start and terminal events, and the activity owner derives the recovery allowance. ### Production size and ownership Runtime production changes total 23 added lines and 24 removed lines, for a net reduction of one line. | File | Net lines | Responsibility | | --- | ---: | --- | | `attempt-bundle-tools.ts` | +2 | Apply the existing lifecycle wrapper before direct or catalog exposure. | | `attempt-tool-prepare.ts` | +17 | Prepare the shared attempt context once. | | `attempt-tool-catalog.ts` | -19 | Reuse that context and remove duplicate construction. | | `attempt.ts` | -1 | Remove the redundant catalog trace argument. | ## User Impact Healthy silent tools receive the existing 15-minute tracked-tool allowance and return their results. ## Evidence `pnpm openclaw agent --agent proof --message 'Run the delayed local tool' --timeout 1000 --json` With tool search disabled, an isolated Gateway, a silent 420-second stdio tool, and `requestTimeoutMs: 900000`: - Before: recovery aborted at 382s, with no result delivered; CLI exit 1. - After: the tool returned at 420s; exactly one trusted start and one completion share the run/session/call correlation. The tool activity retired after completion, the next provider request contained its result, and the final CLI payload contained that result; exit 0. Cancellation, a three-second transport timeout, and catalog execution each recorded one MCP start and terminal event. A hung tool still recovered at 918s. The retained owner/sibling suite passed 387 tests on a merge with main. ## Tests The registered `runEmbeddedAttempt` regression drives real tool-base, bundle, catalog and session adaptation. It checks pending lifecycle correlation, result delivery, and duplicate events in catalog execution. The direct case fails on the baseline; the catalog case passes. Both pass with the fix, alongside ten catalog-abort tests. The hosted selector includes the new test once in `agents-embedded-agent-run`; 737 routing tests passed. The original 38 bundle policy tests remain unchanged. ## Compatibility No timeout policy, configuration key, protocol, or stored-state changes. ### Related recovery behavior This change composes with #148959. Foreground commands retain the accepted process deadline and its final recovery recheck. Configured tools use the existing finite tracked-tool allowance. Cancellation and transport timeouts remain active. ## Consumers Direct and cataloged bundled tools use the same lifecycle boundary. ## Invalidation Terminal events retire activity; permission refresh keeps the current abort signal. ## Evidence limits The measured transport is local stdio with a deterministic loopback provider. The regression controls the transport response while retaining real embedded preparation and session adapters. No channel-delivery or remote-transport behavior is asserted. Co-authored-by: Ayaan Zaidi <[email protected]>
…aw#148959) ## What Problem This Solves Long foreground `exec` calls abort the whole turn after about 15 minutes despite a longer command timeout. Closes openclaw#144514. Thanks @vicvinc for the reports and @alvinveroy for the trace in openclaw#144574. ## Why This Change Was Made The process supervisor is the only mechanism that decides when the command expires; this state has one writer. Exec passes the supervisor's accepted deadline to run activity after preparation. Recovery adds its existing stalled-tool window so process expiry can return a tool error before whole-turn recovery is considered. The final recovery reader rechecks a deadline published after recovery was queued. Explicit cancellation and recovery of commands without an accepted deadline remain enabled. ## User Impact Long commands can finish. Process expiry returns a tool error the turn can handle. Cancellation and genuine-hang recovery remain enabled. ## Evidence Isolated Gateway, deterministic loopback provider, direct tools, `process` denied, default recovery timers: `pnpm openclaw gateway run --port 19463 --bind loopback` `pnpm openclaw agent --agent proof --message 'Run the foreground timeout fixture' --timeout 1800 --json` Baseline `05652685fef2eac618cf75ba95bb3284f04ebb7c`: `sleep 970` with `timeoutSeconds:1400` aborted at 918s. Its failure JSON, recovery logs and transcript remain; the baseline shell exit receipt was lost during an interruption. Built and running correction `b410a592eec3a2c63bd18cdaa75dc29248e4bd40`: the same command completed in 970556 ms, delivered its tool result to the provider, and returned the final answer to the caller (exit 0). Short expiry returned a timeout tool result and final answer (exit 0). No-deadline hang recovery fired at 928s (exit 1). Background expiry also reached a final answer (exit 0). The queued-recovery regression fails on `174d929a` and passes on the correction. The earlier successful live run used ancestor `1da1270`; it is retained as ancestor evidence. 219 tests passed on local merge `006e0ee7`, combining this correction with main `fd5aaff9` and repair openclaw#148933 (`d14f731e`). Main already contained the repair's effect; its local merge changed no files. This proof includes the full exactly-once test-root suite. The repair merge is excluded from this PR. ## Compatibility The change adds an optional, read-only deadline reference to internal diagnostic metadata. The public event payload and declared public metadata fields remain unchanged. Existing diagnostic listeners continue to work. The reference is in-memory only and requires no configuration or stored-data migration. ## Consumers Foreground gateway/sandbox exec and shared recovery, takeover, and admission checks. ## Invalidation Closed invocations reject updates; terminal events retire activity. ## Tests 219 owner/sibling and partition tests passed on the recorded merge. The hosted command selects the new recovery test once; all three cases pass. Locked type preflight, changed-file lint, formatting, line and assertion checks, and dead-export checks passed. No production import or export moved in this correction. <details> <summary>Production growth: +133 lines</summary> Growth accepted under the owner's standing acceptance (2026-09-15). | File | Net lines | Responsibility | | --- | ---: | --- | | `agent-tools.before-tool-call.diagnostics.ts` | +24 | Start lifecycle diagnostics | | `agent-tools.before-tool-call.wrapper.ts` | -2 | Invocation scope and closure | | `bash-tools.exec-runtime.ts` | +2 | Publish accepted deadline | | `diagnostic-events.ts` | +12 | Private metadata handoff | | `diagnostic-tool-execution-liveness.ts` | +69 | Invocation-owned reference | | `diagnostic-run-activity-snapshot.ts` | +9 | Existing recovery window | | `diagnostic-run-activity.ts` | +11 | Retain the live reference | | `diagnostic-stuck-session-recovery.runtime.ts` | +1 | Recheck the current deadline before abort | | `supervisor.ts` | +5 | Project the armed deadline | | `types.ts` | +2 | Read-only deadline contract | </details> Co-authored-by: Ayaan Zaidi <[email protected]>
## What Problem This Solves Silent configured MCP calls were aborted after about six minutes, before their results arrived. Closes openclaw#140671. ## Why This Change Was Made Bundle assembly attaches the existing lifecycle wrapper before direct or catalog exposure. Both paths share one attempt context; this state has one writer. The wrapper emits start and terminal events, and the activity owner derives the recovery allowance. ### Production size and ownership Runtime production changes total 23 added lines and 24 removed lines, for a net reduction of one line. | File | Net lines | Responsibility | | --- | ---: | --- | | `attempt-bundle-tools.ts` | +2 | Apply the existing lifecycle wrapper before direct or catalog exposure. | | `attempt-tool-prepare.ts` | +17 | Prepare the shared attempt context once. | | `attempt-tool-catalog.ts` | -19 | Reuse that context and remove duplicate construction. | | `attempt.ts` | -1 | Remove the redundant catalog trace argument. | ## User Impact Healthy silent tools receive the existing 15-minute tracked-tool allowance and return their results. ## Evidence `pnpm openclaw agent --agent proof --message 'Run the delayed local tool' --timeout 1000 --json` With tool search disabled, an isolated Gateway, a silent 420-second stdio tool, and `requestTimeoutMs: 900000`: - Before: recovery aborted at 382s, with no result delivered; CLI exit 1. - After: the tool returned at 420s; exactly one trusted start and one completion share the run/session/call correlation. The tool activity retired after completion, the next provider request contained its result, and the final CLI payload contained that result; exit 0. Cancellation, a three-second transport timeout, and catalog execution each recorded one MCP start and terminal event. A hung tool still recovered at 918s. The retained owner/sibling suite passed 387 tests on a merge with main. ## Tests The registered `runEmbeddedAttempt` regression drives real tool-base, bundle, catalog and session adaptation. It checks pending lifecycle correlation, result delivery, and duplicate events in catalog execution. The direct case fails on the baseline; the catalog case passes. Both pass with the fix, alongside ten catalog-abort tests. The hosted selector includes the new test once in `agents-embedded-agent-run`; 737 routing tests passed. The original 38 bundle policy tests remain unchanged. ## Compatibility No timeout policy, configuration key, protocol, or stored-state changes. ### Related recovery behavior This change composes with openclaw#148959. Foreground commands retain the accepted process deadline and its final recovery recheck. Configured tools use the existing finite tracked-tool allowance. Cancellation and transport timeouts remain active. ## Consumers Direct and cataloged bundled tools use the same lifecycle boundary. ## Invalidation Terminal events retire activity; permission refresh keeps the current abort signal. ## Evidence limits The measured transport is local stdio with a deterministic loopback provider. The regression controls the transport response while retaining real embedded preparation and session adapters. No channel-delivery or remote-transport behavior is asserted. Co-authored-by: Ayaan Zaidi <[email protected]>
* refactor(agents): centralize tool description exclusions * Merge main into refactor/tool-description-exclusions-20260915 * commit '84114b5a2711764e2ca333e327e808fd88316063': (40 commits) improve(sessions): reuse compiled transcript metadata queries (#148773) fix(ci): repair Copilot contracts and config failure diagnostics (#149001) test: align model auth and setup fixtures with current behavior (#149023) refactor: reuse web search request context (#148949) fix(ci): remove duplicate Copilot auth metadata (#149016) test(agents): align auth fixtures with runtime store reads (#149004) improve: reduce data fetched during reminder maintenance (#148996) fix(cron): skip availability checks when session pruning is idle (#148920) fix(auth): guard GitHub Copilot device flow authority (#148999) fix(agents): prevent early recovery aborts of foreground exec (#148959) fix(github-copilot): remove retired Raptor mini (#116505) improve(feishu): reduce preparation work for documents with tables (#148997) improve: reduce database work when recording participants (#148841) test: accept Bun error labels in plugin assertions (#148955) fix(models): clarify saved account health and catalog status (#148987) test(plugins): align Copilot auth-choice registry expectations (#148981) fix(channels): reject blank integer channel add options (#145534) fix(ui): preserve archive undo after chat navigation (#148831) feat: show cited source previews in macOS and iOS chat (#148906) fix: avoid redundant tab updates while chats stream (#148865) ... * refactor(agents): consolidate tool description exclusions * chore: merge main for tool summary validation * commit '926bb1e1d75c6b102bcbf93114c690312c23cf18': (1903 commits) refactor(matrix): reuse startup verification account key (#157310) perf(config): avoid repeated environment scans during publication (#156457) chore(i18n): refresh native locales (#157495) fix(update): show quiet step progress and date recorded outcomes (#153407) feat(gateway): preserve browser sign-in requirements before connecting (#157454) test(scripts): await CLI admission fixture lifetimes (#157424) fix(ci): preserve consumer selection across core type stripes (#157373) fix(wizard): preserve typed plugin enum values (#127577) (#138090) fix(qa): title mock Code Mode fixture calls refactor: simplify SQLite worker lifecycle and test fixtures (#157458) test: prebuild run-node signal fixture (#157478) refactor(exec): reuse approval policy rule keys (#157198) fix(ci): reuse prepared runtime for changed-target E2E shards (#157365) fix(config): apply Gateway writes without waiting for file events (#157372) fix: count recorded nested tool operations once (#157438) fix(telegram): stop leaking raw file:// markdown links in messages (#137810) refactor(claws): share resource capability changes (#154680) improve(channels): reduce redundant preparation for button messages (#157050) fix(build): package preparation fails on unrelated test types (#157318) refactor(claws): share bounded document reading (#157436) ... Co-authored-by: Vincent Koc <[email protected]>
…8966) * refactor(agents): centralize tool description exclusions * Merge main into refactor/tool-description-exclusions-20260915 * commit '4a994031abb1b54d51b76755a55ac8f6e918162d': (40 commits) improve(sessions): reuse compiled transcript metadata queries (openclaw#148773) fix(ci): repair Copilot contracts and config failure diagnostics (openclaw#149001) test: align model auth and setup fixtures with current behavior (openclaw#149023) refactor: reuse web search request context (openclaw#148949) fix(ci): remove duplicate Copilot auth metadata (openclaw#149016) test(agents): align auth fixtures with runtime store reads (openclaw#149004) improve: reduce data fetched during reminder maintenance (openclaw#148996) fix(cron): skip availability checks when session pruning is idle (openclaw#148920) fix(auth): guard GitHub Copilot device flow authority (openclaw#148999) fix(agents): prevent early recovery aborts of foreground exec (openclaw#148959) fix(github-copilot): remove retired Raptor mini (openclaw#116505) improve(feishu): reduce preparation work for documents with tables (openclaw#148997) improve: reduce database work when recording participants (openclaw#148841) test: accept Bun error labels in plugin assertions (openclaw#148955) fix(models): clarify saved account health and catalog status (openclaw#148987) test(plugins): align Copilot auth-choice registry expectations (openclaw#148981) fix(channels): reject blank integer channel add options (openclaw#145534) fix(ui): preserve archive undo after chat navigation (openclaw#148831) feat: show cited source previews in macOS and iOS chat (openclaw#148906) fix: avoid redundant tab updates while chats stream (openclaw#148865) ... * refactor(agents): consolidate tool description exclusions * chore: merge main for tool summary validation * commit 'e0f58a77476acbe382bff5e55cd520e9d228d478': (1903 commits) refactor(matrix): reuse startup verification account key (openclaw#157310) perf(config): avoid repeated environment scans during publication (openclaw#156457) chore(i18n): refresh native locales (openclaw#157495) fix(update): show quiet step progress and date recorded outcomes (openclaw#153407) feat(gateway): preserve browser sign-in requirements before connecting (openclaw#157454) test(scripts): await CLI admission fixture lifetimes (openclaw#157424) fix(ci): preserve consumer selection across core type stripes (openclaw#157373) fix(wizard): preserve typed plugin enum values (openclaw#127577) (openclaw#138090) fix(qa): title mock Code Mode fixture calls refactor: simplify SQLite worker lifecycle and test fixtures (openclaw#157458) test: prebuild run-node signal fixture (openclaw#157478) refactor(exec): reuse approval policy rule keys (openclaw#157198) fix(ci): reuse prepared runtime for changed-target E2E shards (openclaw#157365) fix(config): apply Gateway writes without waiting for file events (openclaw#157372) fix: count recorded nested tool operations once (openclaw#157438) fix(telegram): stop leaking raw file:// markdown links in messages (openclaw#137810) refactor(claws): share resource capability changes (openclaw#154680) improve(channels): reduce redundant preparation for button messages (openclaw#157050) fix(build): package preparation fails on unrelated test types (openclaw#157318) refactor(claws): share bounded document reading (openclaw#157436) ... Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Long foreground
execcalls abort the whole turn after about 15 minutes despite a longer command timeout.Closes #144514. Thanks @vicvinc for the reports and @alvinveroy for the trace in #144574.
Why This Change Was Made
The process supervisor is the only mechanism that decides when the command expires; this state has one writer. Exec passes the supervisor's accepted deadline to run activity after preparation. Recovery adds its existing stalled-tool window so process expiry can return a tool error before whole-turn recovery is considered. The final recovery reader rechecks a deadline published after recovery was queued. Explicit cancellation and recovery of commands without an accepted deadline remain enabled.
User Impact
Long commands can finish. Process expiry returns a tool error the turn can handle. Cancellation and genuine-hang recovery remain enabled.
Evidence
Isolated Gateway, deterministic loopback provider, direct tools,
processdenied, default recovery timers:pnpm openclaw gateway run --port 19463 --bind loopbackpnpm openclaw agent --agent proof --message 'Run the foreground timeout fixture' --timeout 1800 --jsonBaseline
0945dabbe487213e95e84a72ad1aae3659e0e000:sleep 970withtimeoutSeconds:1400aborted at 918s. Its failure JSON, recovery logs and transcript remain; the baseline shell exit receipt was lost during an interruption.Built and running correction
b410a592eec3a2c63bd18cdaa75dc29248e4bd40: the same command completed in 970556 ms, delivered its tool result to the provider, and returned the final answer to the caller (exit 0). Short expiry returned a timeout tool result and final answer (exit 0). No-deadline hang recovery fired at 928s (exit 1). Background expiry also reached a final answer (exit 0).The queued-recovery regression fails on
174d929aand passes on the correction. The earlier successful live run used ancestor1da1270; it is retained as ancestor evidence.219 tests passed on local merge
006e0ee7, combining this correction with main55947755and repair #148933 (d14f731e). Main already contained the repair's effect; its local merge changed no files. This proof includes the full exactly-once test-root suite. The repair merge is excluded from this PR.Compatibility
The change adds an optional, read-only deadline reference to internal diagnostic metadata. The public event payload and declared public metadata fields remain unchanged. Existing diagnostic listeners continue to work. The reference is in-memory only and requires no configuration or stored-data migration.
Consumers
Foreground gateway/sandbox exec and shared recovery, takeover, and admission checks.
Invalidation
Closed invocations reject updates; terminal events retire activity.
Tests
219 owner/sibling and partition tests passed on the recorded merge. The hosted command selects the new recovery test once; all three cases pass. Locked type preflight, changed-file lint, formatting, line and assertion checks, and dead-export checks passed. No production import or export moved in this correction.
Production growth: +133 lines
Growth accepted under the owner's standing acceptance (2026-09-15).
agent-tools.before-tool-call.diagnostics.tsagent-tools.before-tool-call.wrapper.tsbash-tools.exec-runtime.tsdiagnostic-events.tsdiagnostic-tool-execution-liveness.tsdiagnostic-run-activity-snapshot.tsdiagnostic-run-activity.tsdiagnostic-stuck-session-recovery.runtime.tssupervisor.tstypes.ts