Skip to content

fix: resume tasks after tools finish and the model times out - #147203

Merged
VACInc merged 2 commits into
openclaw:mainfrom
VACInc:fix/continue-settled-timeout
Sep 13, 2026
Merged

VACInc merged 2 commits into
openclaw:mainfrom
VACInc:fix/continue-settled-timeout

Conversation

@VACInc

@VACInc VACInc commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Summary

High Level TLDR

An embedded task could stop with a progress summary when the model idled out after finishing tool calls. Resume from the recorded results with tools available, preserving completed work and the existing retry limits.

What Problem This Solves

Fixes unfinished tasks requiring another user message to continue after a model idle timeout following settled tool activity.

User Impact

The agent can continue the remaining work, including investigating a recorded tool failure. Cancellation, pending approval, unfinished or asynchronous tools, deliberate tool termination, native harness ownership, and run/retry limits keep their existing boundaries. No configuration or migration is required.

Why This Change Was Made

The existing transient recovery owner already resumes the saved transcript without resubmitting the original request. Allow that path for an embedded prompt idle timeout when the latest tool batch has matching recorded results and every lifecycle item has settled. Keep the original-prompt replay and model-switch gates unchanged.

Root Cause

Observed attempts had an idle timeout after all tool calls finished, with no external cancellation or tool/compaction/run-budget timeout. recoverEmbeddedRunAttempt rejected continuation because side effects made currentAttemptReplaySafe false. Recovery then selected settled-tool-finalization, which disables tools and returns a summary as a successful result despite unfinished work.

This completes the no-replay repair introduced in #122516 (August 12): that PR explicitly introduced and tested summary-only finalization for this case. #130721 (August 27) restored recorded-transcript continuation after transport drops, and #139397 (September 5) generalized transient recovery; both retained the idle-timeout exclusion. The earlier implementation did not establish safe continuation either, so this is a missing recovery path left by those repairs.

Related #141072 addresses reporting when summary recovery is empty or fails. This change instead restores task continuation before summary-only recovery is reached.

CI integration repair

The first hosted run tested the PR merged with 1d879559c3b7 and caught an unrelated missing await in the Workboard concurrent attachment-deletion test added on main after this branch started. The branch now includes that same upstream base and awaits the existing async harness.close() before its test returns. This is a one-line test cleanup repair; the continuation implementation is unchanged. Original failing lint job.

Evidence

Real behavior proof

The closest feasible deterministic proof runs the public runEmbeddedAgent entry point with synthetic attempt results and isolated test state. The fixture requests a write followed by verification, records the completed write, then injects a prompt idle timeout. It checks the next attempt's actual dispatch parameters and returned payload.

  • Baseline 4b2b59362dec62f34576812124249389c42d9651: the embedded regression fails because the next prompt says, “Tools are unavailable in this step”; the native harness control passes.
  • Patched: embedded recovery schedules a normal attempt with tools enabled and a hidden continuation instruction; it does not reinsert the original user request, change auth/model, or enter summary-only finalization. The native harness control retains its finalization behavior.
  • The recovery-owner regressions fail on the baseline with action: proceed and pass after the patch with action: retry, for both successful and failed settled tool results. Missing results, active lifecycle items, async work, deliberate termination, approval, yielding, native transport ownership, and timeout/budget exclusions are covered.

Verification

Linux x64, Node 24.19.0. Commands run in an isolated worktree:

node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt-recovery.test.ts src/agents/embedded-agent-runner/run/settled-tool-evidence.test.ts src/agents/embedded-agent-runner/run/settled-turn-finalization.test.ts src/agents/embedded-agent-runner/run/failover-retry-controller.test.ts --reporter=dot
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.shared-integration.test.ts --reporter=dot
node scripts/check-changed.mjs -- src/agents/embedded-agent-runner/run/attempt-recovery.ts src/agents/embedded-agent-runner/run/attempt-recovery.test.ts src/agents/embedded-agent-runner/run.prompt-timeout-fallback.test-support.ts docs/concepts/retry.md
  • Focused recovery/finalization tests: 146 passed.
  • Public runner integration group: 120 passed.
  • Core changed-file repository checks: passed, including production/test typechecks, type-aware lint, formatting, dependency/schema guards, and import-cycle checks.
  • CI cleanup repair: the existing concurrent attachment-recreation test passed; type-aware lint of extensions/workboard/src/store.test.ts passed.
  • Renewed independent autoreview of the complete five-file candidate: scoped clean through P2; no actionable findings.
  • Hosted CI for 7a8fb93f3a2: exact-head run.
  • ClawSweeper review of 7a8fb93f3a2: no correctness/security findings; ready for maintainer review with no requested changes.
Repeatable recovery-owner microbenchmark

Same existing recoverAfterTransportDrop fixture, with a settled side-effecting batch and { kind: "timeout", phase: "prompt", source: "idle" }. Run 100 warmups and 1,000 fresh-controller samples per revision, using the baseline production owner and then the patched owner with the same test fixture. Provider calls and backoff are stubbed; this measures recovery routing/fixture overhead, not model latency or tool execution.

Revision Continuations Median p95 Mean
Baseline 0 / 1,000 0.0685 ms 0.1258 ms 0.1060 ms
7a8fb93f3a2 1,000 / 1,000 0.0833 ms 0.1301 ms 0.1086 ms

Reproduce in an isolated checkout by generating this temporary test beside attempt-recovery.test.ts, keeping that file's imports and fixture definitions before its top-level describe("recoverEmbeddedRunAttempt", ...), followed by:

describe("settled idle timeout recovery overhead", () => {
  it("samples the recovery owner", async () => {
    const samples: number[] = [];
    let continued = 0;
    for (let index = -100; index < 1000; index++) {
      const start = performance.now();
      const result = await recoverAfterTransportDrop({
        terminal: { kind: "timeout", phase: "prompt", source: "idle" },
      });
      const elapsed = performance.now() - start;
      if (index >= 0) {
        samples.push(elapsed);
        continued += Number(result.continueFromCurrentTranscript.mock.calls.length === 1);
      }
    }
    samples.sort((a, b) => a - b);
    console.info({ continued, medianMs: samples[500], p95Ms: samples[950],
      meanMs: samples.reduce((a, b) => a + b, 0) / samples.length });
    expect(samples).toHaveLength(1000);
  });
});

Run node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt-recovery-benchmark.test.ts --reporter=dot for each production revision. Remove only the generated test afterward. No benchmark-only production seam or test configuration is added.

What was not tested

No live provider, Telegram, or physical-device execution was performed with the patch, and it has not been deployed. The integration fixture injects attempt results; it does not prove a model will choose the intended next tool. This PR does not change normal model final responses or fix the separate synchronous transcript-rewrite starvation tracked in #119720.

@clawsweeper

clawsweeper Bot commented Sep 13, 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 agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 1:39 PM ET / 17:39 UTC (Revision 3).

ClawSweeper review

What this changes

The embedded agent resumes unfinished tasks after settled tools and a model idle timeout, with regression coverage, retry documentation, and an awaited Workboard test cleanup.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and v2026.9.4 retain the idle-timeout exclusion, and the related summary-recovery fix addresses a different outcome. No actionable correctness or security findings remain.

Priority: P2
Reviewed head: 7a8fb93f3a2fc2eeaedac4f71f1d66fe8ab48d3b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful baseline-failing regression coverage, clear evidence limits, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its public-runner fixture verifies continuation dispatch using synthetic attempt results, not live model or tool execution; the supplied body explicitly discloses that limit.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its public-runner fixture verifies continuation dispatch using synthetic attempt results, not live model or tool execution; the supplied body explicitly discloses that limit.
Evidence reviewed 10 items Pinned source and protected status: The repository remote identifies openclaw/openclaw. Live GitHub metadata confirms the PR is open and unmerged, authored by a MEMBER, with head 7a8fb93. The supplied context also carries the protected maintainer label.
Recovery predicate and exclusions: The introduced predicate requires recorded settlement, excludes intentional termination, asynchronous activity, and pending approval, and enters the existing transient controller. Surrounding guards retain external cancellation, run-budget, compaction, tool-timeout, yield, client-tool, and harness exclusions; replay-unsafe attempts still cannot reach ordinary prompt replay or profile rotation.
Existing settlement owner: Settlement matches the latest user-turn tool calls with subsequent results by call ID and tool name, then requires positive lifecycle starts, equal completion counts, and zero active items. The patch reuses this owner instead of adding another settlement policy.
Findings None None.
Security None None.

How this fits together

The embedded agent runner coordinates model requests, tool execution, and recovery within an admitted task. Recovery consumes recorded tool results and timeout facts to choose another attempt or a terminal response.

flowchart TD
  A[User task] --> B[Model and tool execution]
  B --> C[Recorded results and idle timeout]
  C --> D{Tools settled and recovery allowed?}
  D -->|Yes| E[Existing bounded retry controller]
  E --> F[Continue transcript with tools available]
  D -->|No| G[Existing terminal handling]
  F --> B
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +10, Tests +85, Docs +2. Total +97 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 12 2 +10
Tests 3 181 96 +85
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 195 98 +97

Review metrics

None.

Technical review

Best possible solution:

Keep settled idle-timeout continuation in the existing recovery owner, preserving transcript results, bounded retries, and the same admitted run.

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

Yes, from source: a settled side-effecting tool batch followed by a prompt idle timeout fails main's replay-safe continuation gate and reaches tools-disabled finalization. The submitted baseline-failing regressions support this path; no runtime reproduction was executed here.

Is this the best way to solve the issue?

Yes. The patch narrowly extends the existing transcript-continuation mechanism while retaining settlement, cancellation, harness ownership, and retry-budget checks.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs a bounded recovery failure that can leave tool-heavy tasks unfinished after a model idle timeout.
  • 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 MEMBER-authored PR is exempt from the external-contributor proof gate. Its public-runner fixture verifies continuation dispatch using synthetic attempt results, not live model or tool execution; the supplied body explicitly discloses that limit.

Evidence

What I checked:

  • Pinned source and protected status: The repository remote identifies openclaw/openclaw. Live GitHub metadata confirms the PR is open and unmerged, authored by a MEMBER, with head 7a8fb93. The supplied context also carries the protected maintainer label. (7a8fb93f3a2f)
  • Recovery predicate and exclusions: The introduced predicate requires recorded settlement, excludes intentional termination, asynchronous activity, and pending approval, and enters the existing transient controller. Surrounding guards retain external cancellation, run-budget, compaction, tool-timeout, yield, client-tool, and harness exclusions; replay-unsafe attempts still cannot reach ordinary prompt replay or profile rotation. (src/agents/embedded-agent-runner/run/attempt-recovery.ts:124, 7a8fb93f3a2f)
  • Existing settlement owner: Settlement matches the latest user-turn tool calls with subsequent results by call ID and tool name, then requires positive lifecycle starts, equal completion counts, and zero active items. The patch reuses this owner instead of adding another settlement policy. (src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts:246, 7a8fb93f3a2f)
  • Continuation preserves existing run authority: Each retry checks cancellation and the existing admitted-run assertion before dispatch. The continuation changes model-only instructions and suppresses another persisted user request; it does not mint authority or change the authorized principal. (src/agents/embedded-agent-runner/run-loop.ts:294, 7a8fb93f3a2f)
  • Current-main necessity: The recovery owner on fetched main still has the original replay-safe-only interruption gate; comparison with the reviewed head shows precisely the proposed settled-idle exception remains absent. (src/agents/embedded-agent-runner/run/attempt-recovery.ts:311, f96fed1a7cc0)
  • Latest release comparison: The same replay-safe-only interruption gate is present in v2026.9.4; the requested continuation is not supplied by that release. (src/agents/embedded-agent-runner/run/attempt-recovery.ts:311, 3a9d69db306c)

Likely related people:

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

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-13T17:12:17.510Z sha 53fc0d6 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T17:28:10.673Z sha 7a8fb93 :: needs maintainer review before merge. :: none

@VACInc

VACInc commented Sep 13, 2026

Copy link
Copy Markdown
Member Author

Updated head: 7a8fb93f3a2fc2eeaedac4f71f1d66fe8ab48d3b.

The first CI run found a missing await in a Workboard test on the newer main used for its merge build. This update incorporates that tested base and awaits the test's async cleanup. The continuation implementation is unchanged. The affected attachment-recreation test and type-aware lint pass; renewed autoreview of the complete candidate found no actionable issues. Hosted CI is running again.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@VACInc
VACInc enabled auto-merge (squash) September 13, 2026 17:46
@VACInc
VACInc merged commit fc19759 into openclaw:main Sep 13, 2026
226 of 227 checks passed
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '201f11afefdb19a9c75e9d3542bf7425c80df7a7': (141 commits)
  fix: keep catalog discovery scoped and execution lazy (#147159)
  fix: serialize reclamation worker shutdown with foreground writes (#147178)
  test(sessions): cover abrupt committed transcript recovery (#143984)
  fix: stop transcript storms during context overflow recovery (#147202)
  fix: reduce CPU overhead for small history and usage reads (#147205)
  fix: resume tasks after tools finish and the model times out (#147203)
  refactor(scripts): share SQLite reliability message waits (#146900)
  feat(exec): configure approval reviewer thinking and fastMode (#147192)
  test: remove redundant Bonjour module headers (#146981)
  refactor: share streaming media tail boundary update (#146989)
  refactor(tui): classify resume candidates once (#146983)
  improve: skip unused toast dismissal work (#147196)
  fix(linux): recover saved remote connections without replacing active sessions (#146047)
  fix: doctor stays silent when Windows state dir is under OneDrive (#123720)
  feat: announce successful Daybreak retries (#147146)
  feat(code-mode): reuse results across code cells (#147154)
  refactor(test): reuse CLI plugin fixture writer (#147186)
  test: skip unused compiler setup in routing fixtures (#147194)
  test: reuse LINE webhook runtime fixture (#146710)
  fix(code-mode): check automation and process result types (#147143)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '2d87daf04b78992382299d552f15ac84a86a23ed': (1815 commits)
  fix(ui): distinguish tool activity with semantic icons (#147207)
  fix(linux): recover completed Quick Chat replies without resending (#146048)
  feat(desktop): unify Tauri title bar and window controls (#147097)
  refactor(test): share plugin fixture server shims (#147225)
  perf(gateway): defer worker workspace execution imports (#143496)
  fix(gateway): post-ack webhook work fails with "Async work scope is closed" (#144801)
  refactor(scripts): centralize upgrade survivor version floors (#146975)
  fix(ci): check publication registries before FRV fanout (#147184)
  fix(qa): align system-agent delegation with channel contracts (#145905)
  improve: reduce repeated chat message identity work (#147210)
  fix(channels): remove stale pre-tool previews from Slack and Telegram (#147106)
  fix: keep catalog discovery scoped and execution lazy (#147159)
  fix: serialize reclamation worker shutdown with foreground writes (#147178)
  test(sessions): cover abrupt committed transcript recovery (#143984)
  fix: stop transcript storms during context overflow recovery (#147202)
  fix: reduce CPU overhead for small history and usage reads (#147205)
  fix: resume tasks after tools finish and the model times out (#147203)
  refactor(scripts): share SQLite reliability message waits (#146900)
  feat(exec): configure approval reviewer thinking and fastMode (#147192)
  test: remove redundant Bonjour module headers (#146981)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. plugin: workboard 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.

1 participant