Skip to content

fix(agents): prevent early recovery aborts of foreground exec - #148959

Merged
obviyus merged 4 commits into
mainfrom
bugloop/exec-foreground-deadline-handoff
Sep 15, 2026
Merged

obviyus merged 4 commits into
mainfrom
bugloop/exec-foreground-deadline-handoff

Conversation

@obviyus

@obviyus obviyus commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Long foreground exec calls 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, 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 0945dabbe487213e95e84a72ad1aae3659e0e000: 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 55947755 and 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).

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

@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 15, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 6:29 AM ET / 10:29 UTC (Revision 2).

ClawSweeper review

What this changes

The 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
Reviewed head: b410a592eec3a2c63bd18cdaa75dc29248e4bd40

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant real Gateway observations and regression coverage; no blocking correctness finding remains.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured PR body records the pinned correction exercising wrapped foreground exec through an isolated Gateway and real process execution: the long command completes, timeout becomes a tool result, and no-deadline recovery remains active. Mocked-adapter regressions supplement these live observations.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured PR body records the pinned correction exercising wrapped foreground exec through an isolated Gateway and real process execution: the long command completes, timeout becomes a tool result, and no-deadline recovery remains active. Mocked-adapter regressions supplement these live observations.
Evidence reviewed 10 items Verified review scope: The checkout is the pinned original head b410a59. Review used the merge-base-to-head introduced changes; endpoint drift and the stale test merge were not treated as PR changes. The final working-tree status remained clean.
Supervisor-owned deadline handoff: The supervisor projects its armed monotonic timeout as an absolute deadline, and exec records that accepted value after process preparation. The invocation-scoped reference rejects updates after close or cancellation; terminal diagnostics remove its activity marker.
Queued recovery revalidation: Recovery now evaluates the current shared threshold when a tool deadline appeared after recovery was queued. The new production-boundary regression covers future, expired, and absent deadlines; the PR body reports failure on the preceding head and success on the correction.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +133, Tests +410. Total +543 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 10 145 12 +133
Tests 2 410 0 +410
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 555 12 +543

Review metrics

Metric Value Why it matters
Production versus regression coverage production net +133 lines; tests +410 lines Production growth supplies the invocation-scoped deadline handoff and final recovery check; the PR body explains each responsibility.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #144514
Summary: This PR is the candidate fix for the canonical long-exec recovery report; the supplemental bare-sleep trace describes the same failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best 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.

Labels

Label justifications:

  • P1: Reported foreground commands terminate whole agent turns before their accepted timeout, interrupting established agent workflows.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured PR body records the pinned correction exercising wrapped foreground exec through an isolated Gateway and real process execution: the long command completes, timeout becomes a tool result, and no-deadline recovery remains active. Mocked-adapter regressions supplement these live observations.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR body records the pinned correction exercising wrapped foreground exec through an isolated Gateway and real process execution: the long command completes, timeout becomes a tool result, and no-deadline recovery remains active. Mocked-adapter regressions supplement these live observations.

Evidence

What I checked:

  • Verified review scope: The checkout is the pinned original head b410a59. Review used the merge-base-to-head introduced changes; endpoint drift and the stale test merge were not treated as PR changes. The final working-tree status remained clean. (b410a592eec3)
  • Supervisor-owned deadline handoff: The supervisor projects its armed monotonic timeout as an absolute deadline, and exec records that accepted value after process preparation. The invocation-scoped reference rejects updates after close or cancellation; terminal diagnostics remove its activity marker. (src/agents/bash-tools.exec-runtime.ts:1021, b410a592eec3)
  • Queued recovery revalidation: Recovery now evaluates the current shared threshold when a tool deadline appeared after recovery was queued. The new production-boundary regression covers future, expired, and absent deadlines; the PR body reports failure on the preceding head and success on the correction. (src/logging/diagnostic-stuck-session-recovery.runtime.ts:97, b410a592eec3)
  • Current main still lacks the handoff: Fetched main records only the deadline present on the start event, while its exec runtime assigns process activity without publishing the supervisor deadline. The existing shared threshold therefore does not by itself solve the reported foreground-exec failure. (src/logging/diagnostic-run-activity.ts:111, 2b8c9f1ad64a)
  • Latest-release comparison: The v2026.9.4 activity recorder likewise reads only event.deadlineAtMs. Its source was inspected through the GitHub contents API after local historical-blob retrieval failed; no shipped implementation of this handoff was established. (src/logging/diagnostic-run-activity.ts:107, 3a9d69db306c)
  • Recorded real Gateway behavior: The complete supplied PR body, captured under sourceRevision c805c0ace1153f5ae937144dbc7bc9c862835ab5622a18c999aecaff37f48775, records an isolated Gateway with a loopback provider, direct tools, process denied, and default recovery timers. Baseline sleep 970 with timeoutSeconds 1400 aborted at 918 seconds; the pinned correction completed in 970556 ms, delivered the tool result, and returned a final answer with exit 0. Short timeout, no-deadline recovery, and background expiry observations are also recorded. These are contributor-recorded live observations; this read-only review did not execute tests or runtime commands. (b410a592eec3)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-15T09:21:54.171Z sha 174d929 :: needs changes before merge. :: none

@obviyus

obviyus commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 148959
head: b410a59
scope: owner-review

@obviyus
obviyus marked this pull request as ready for review September 15, 2026 10:23
@obviyus

obviyus commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-unrelated-red
pr: 148959
head: b410a59
run: 34957687007 attempt: 1
failed: checks-fast-contracts-plugins job=104344223282 conclusion=failure
failed: checks-node-compact-large-10 job=104344224330 conclusion=failure
failed: checks-node-compact-large-7 job=104344224583 conclusion=failure
failed: checks-node-compact-large-8 job=104344223998 conclusion=failure
failed: checks-node-compact-small-2 job=104344222986 conclusion=failure
check: openclaw/ci-gate

@obviyus
obviyus merged commit 7df9f83 into main Sep 15, 2026
251 of 259 checks passed
@obviyus
obviyus deleted the bugloop/exec-foreground-deadline-handoff branch September 15, 2026 10:58
@obviyus

obviyus commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator Author

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.

  • Bug: Stuck-session recovery aborted long foreground commands before their declared timeout.
  • Fix: Exec passes the process supervisor's accepted deadline to recovery, which checks it again before a queued abort.
Before After
The command and whole turn aborted after about 15 minutes. The command gets its accepted lifetime; its own timeout returns a tool error the turn can handle.

vincentkoc added a commit that referenced this pull request Sep 15, 2026
* 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)
vincentkoc added a commit that referenced this pull request Sep 15, 2026
* 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)
  ...
vincentkoc added a commit that referenced this pull request Sep 15, 2026
* 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)
  ...
obviyus added a commit that referenced this pull request Sep 15, 2026
## 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
## 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]>
vincentkoc added a commit that referenced this pull request Sep 24, 2026
* 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exec tool timeout (~900s) aborts the whole run as OPENCLAW_DIRECT_ABORT instead of returning a tool error

1 participant