Skip to content

fix: preserve agent timeouts after background commands complete - #148388

Merged
steipete merged 1 commit into
mainfrom
codex/fix-exec-continuation-timeout
Sep 14, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-exec-continuation-timeout

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes unfinished agent tasks timing out ten minutes after a background command completes and wakes the session, even while the agent is actively making progress.

User Impact

Command-completion continuations use the ordinary agent timeout, including configured finite limits and 0 for no timeout. Scheduled heartbeat work retains its existing limits. No configuration changes or migrations are required.

Why This Change Was Made

The heartbeat runner also transports command-completion events. Select the timeout from the prepared prompt's owner: an actual exec completion leaves timeout resolution to the existing agent owner, while monitor turns retain the heartbeat override. This also covers completions carried by hooks and preserves scheduled-task precedence over queued completions.

Evidence

  • Six regression cases fail on the original code with the heartbeat's 600-second or explicit 45-second deadline. The scheduled-task control and existing heartbeat controls pass.
  • After the fix, 84 tests pass across timeout selection, reminder handling, stale/coalesced completions, and event routing, including isolated conversations.
  • Independent Codex autoreview found no actionable P0–P2 findings; ClawSweeper also found no correctness or security defects. Deslop and git diff --check passed.
  • Repository changed checks (including core and test typechecks, lint, export scans, and guards) and documentation checks passed. Exact-head CI passed; all 141 PR checks passed on 6aed14fca6e1d3d78dd0f59ebd455fa9717cec49.

Completion turns resume unfinished agent work through the heartbeat runner. Use the existing prepared exec-completion classification to leave their deadline with the ordinary agent timeout resolver, while retaining heartbeat budgets for monitor and scheduled-task prompts.

Regression proof: six cases fail before the fix; 84 focused tests pass afterward. Changed checks, documentation checks, deslop, and independent review pass.
@steipete
steipete marked this pull request as ready for review September 14, 2026 16:37
@clawsweeper

clawsweeper Bot commented Sep 14, 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 docs Improvements or additions to documentation gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 1:03 PM ET / 17:03 UTC.

ClawSweeper review

What this changes

Command-completion continuations use the ordinary agent timeout, while scheduled heartbeat work retains its existing limits, with regression coverage and documentation.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary: current main and the latest release still impose heartbeat deadlines on command-completion continuations. No actionable correctness or security defect was found in the introduced patch.

Priority: P1
Reviewed head: 6aed14fca6e1d3d78dd0f59ebd455fa9717cec49

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository context identifies maintainer-authored work, so the external-contributor proof gate does not apply; inspected tests cover timeout selection at the heartbeat entry point but do not demonstrate a live long-running continuation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository context identifies maintainer-authored work, so the external-contributor proof gate does not apply; inspected tests cover timeout selection at the heartbeat entry point but do not demonstrate a live long-running continuation.
Evidence reviewed 7 items Introduced timeout selection: The pinned introduced patch omits the heartbeat timeout override only when the prepared turn is an exec completion; existing cancellation and reply dispatch remain intact.
Current main still needs the repair: The fetched main revision passes resolveHeartbeatTimeoutOverrideSeconds unconditionally, including turns classified as exec completions.
Latest release retains the old behavior: The v2026.9.4 runner also applies the heartbeat override unconditionally, and its resolver caps an unset deadline at 600 seconds.
Findings None None.
Security None None.

How this fits together

OpenClaw’s heartbeat runner handles both scheduled monitoring and events that resume agent work after background commands finish. It prepares the turn and passes timeout options to the shared reply runtime.

flowchart TD
  A[Background command completes] --> C[Prepare heartbeat turn]
  B[Scheduled monitoring] --> C
  C --> D{Completion continuation?}
  D -->|Yes| E[Ordinary agent timeout]
  D -->|No| F[Heartbeat timeout]
  E --> G[Shared reply runtime]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +2, Tests +91, Docs +1. Total +94 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 5 3 +2
Tests 1 91 0 +91
Docs 1 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 98 4 +94

Review metrics

None.

Technical review

Best possible solution:

Keep timeout policy with the existing agent resolver for completion continuations and the heartbeat resolver for monitoring turns.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: an exec-completion turn with a 30-minute heartbeat cadence and no explicit agent timeout receives a 600-second override on current main. Runtime reproduction was not executed.

Is this the best way to solve the issue?

Yes. Reusing the prepared completion classification and existing agent timeout resolver is a narrow repair that preserves scheduled-task precedence without adding configuration or another timeout policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against cb5c760d943e.

Labels

Label changes:

  • add P1: The existing deadline can interrupt actively progressing agent work after a background command completes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository context identifies maintainer-authored work, so the external-contributor proof gate does not apply; inspected tests cover timeout selection at the heartbeat entry point but do not demonstrate a live long-running continuation.

Label justifications:

  • P1: The existing deadline can interrupt actively progressing agent work after a background command completes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository context identifies maintainer-authored work, so the external-contributor proof gate does not apply; inspected tests cover timeout selection at the heartbeat entry point but do not demonstrate a live long-running continuation.

Evidence

What I checked:

  • Introduced timeout selection: The pinned introduced patch omits the heartbeat timeout override only when the prepared turn is an exec completion; existing cancellation and reply dispatch remain intact. (src/infra/heartbeat-runner-run.ts:127, 6aed14fca6e1)
  • Current main still needs the repair: The fetched main revision passes resolveHeartbeatTimeoutOverrideSeconds unconditionally, including turns classified as exec completions. (src/infra/heartbeat-runner-run.ts:127, cb5c760d943e)
  • Latest release retains the old behavior: The v2026.9.4 runner also applies the heartbeat override unconditionally, and its resolver caps an unset deadline at 600 seconds. (src/infra/heartbeat-runner-run.ts:127, 3a9d69db306c)
  • Existing timeout owner and scheduled-task precedence: The ordinary resolver already handles the 48-hour default, configured finite limits, and zero sentinel. Prompt preparation clears hasExecCompletion when scheduled tasks take precedence, preserving their heartbeat budget. (src/infra/heartbeat-runner-prompt.ts:247, 6aed14fca6e1)
  • Regression coverage and execution limits: Seven added cases exercise runHeartbeatOnce and inspect effective timeout selection, including hook-carried completions, disabled cadence, finite and unlimited agent settings, and scheduled-task precedence. The captured PR body reports six baseline failures and 84 passing focused tests afterward; these results were not rerun during this read-only review. The read-only diff whitespace check passed. (src/infra/heartbeat-runner.model-override.test.ts:218, 6aed14fca6e1)
  • Feature-history routing: Main history identifies Peter Steinberger’s heartbeat/reply-runtime refactoring and completion-wake work, plus Peter Lee’s configured-heartbeat-timeout repair. Exact line-introduction attribution was not established; the blame attempt could not retrieve a required historical object. (src/infra/heartbeat-runner-config.ts, cb5c760d943e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Lee: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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.

@steipete
steipete merged commit 2587f8e into main Sep 14, 2026
262 checks passed
@steipete
steipete deleted the codex/fix-exec-continuation-timeout branch September 14, 2026 17:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 14, 2026
Remove the unreachable message-specific configuration branch after the dynamic-tool resolver early return. Inline the private announcement failure formatter into its only exported caller, preserving exact output and timeout behavior.

Validation: 353 focused tests, changed-file checks, and independent review through P2 passed. Follow-up cleanup from the timeout ownership audit after #148388.
steipete added a commit that referenced this pull request Sep 14, 2026
* refactor: simplify timeout and announcement helpers

Remove the unreachable message-specific configuration branch after the dynamic-tool resolver early return. Inline the private announcement failure formatter into its only exported caller, preserving exact output and timeout behavior.

Validation: 353 focused tests, changed-file checks, and independent review through P2 passed. Follow-up cleanup from the timeout ownership audit after #148388.

* fix(ci): remove duplicate Wizard recovery test registration

The compact Node planner correctly refuses repeated file identities. Remove the second registry entry while preserving all 68 unique database-worker consumers and their execution owner. This is the same inherited CI correction identified in #148423 and #148425.

Validation: reproduced the original preflight error, all six planner profiles now generate, 76 planner tests and scoped changed checks pass, and independent review of the complete candidate is clean through P2.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
…claw#148388)

Completion turns resume unfinished agent work through the heartbeat runner. Use the existing prepared exec-completion classification to leave their deadline with the ordinary agent timeout resolver, while retaining heartbeat budgets for monitor and scheduled-task prompts.

Regression proof: six cases fail before the fix; 84 focused tests pass afterward. Changed checks, documentation checks, deslop, and independent review pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
* refactor: simplify timeout and announcement helpers

Remove the unreachable message-specific configuration branch after the dynamic-tool resolver early return. Inline the private announcement failure formatter into its only exported caller, preserving exact output and timeout behavior.

Validation: 353 focused tests, changed-file checks, and independent review through P2 passed. Follow-up cleanup from the timeout ownership audit after openclaw#148388.

* fix(ci): remove duplicate Wizard recovery test registration

The compact Node planner correctly refuses repeated file identities. Remove the second registry entry while preserving all 68 unique database-worker consumers and their execution owner. This is the same inherited CI correction identified in openclaw#148423 and openclaw#148425.

Validation: reproduced the original preflight error, all six planner profiles now generate, 76 planner tests and scoped changed checks pass, and independent review of the complete candidate is clean through P2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant