Skip to content

fix: skip timeout compaction when run was aborted by user#80746

Closed
lykeion-dev wants to merge 1 commit into
openclaw:mainfrom
lykeion-dev:fix/skip-timeout-compaction-on-abort
Closed

fix: skip timeout compaction when run was aborted by user#80746
lykeion-dev wants to merge 1 commit into
openclaw:mainfrom
lykeion-dev:fix/skip-timeout-compaction-on-abort

Conversation

@lykeion-dev

Copy link
Copy Markdown

No description provided.

When the user presses the stop button in the Control UI, the model
request times out. Previously, if context token usage exceeded 65%,
the timeout compaction mechanism would fire even though the run was
intentionally aborted — causing unnecessary compaction at an
inappropriate time.

Add !aborted check to the timeout compaction condition so that
user-initiated stops skip compaction entirely.
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling triage: blank-template Candidate: PR template appears mostly untouched. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. size: XS labels May 11, 2026
@clawsweeper

clawsweeper Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR adds an !aborted guard to timeout-triggered compaction in runEmbeddedPiAgent and rewrites related tests to expect skipped compaction for aborted timeouts.

Reproducibility: yes. for the PR-introduced regression by source inspection: ordinary timeouts call abortRun(true), which sets both aborted and timedOut, so the proposed guard skips timeout compaction. No live proof was provided for the contributor's claimed Control UI stop scenario.

Real behavior proof
Needs real behavior proof before merge: Missing: the PR body/comments contain no after-fix real Control UI stop proof; add redacted screenshot, recording, terminal output, logs, or a linked artifact to the PR body so ClawSweeper can re-review, or ask a maintainer to comment @clawsweeper re-review if it does not run automatically. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Next step before merge
Needs contributor changes plus real behavior proof; automation should not repair this external PR before the claimed stop-flow behavior is proven.

Security
Cleared: The diff only changes agent runner control flow and tests; no dependency, workflow, secret, or supply-chain surface is added.

Review findings

  • [P1] Preserve timeout compaction for internal timeouts — src/agents/pi-embedded-runner/run.ts:1560
Review details

Best possible solution:

Preserve normal timeout-triggered compaction for internal timeouts while adding a targeted user-abort guard, likely based on externalAbort or abort reason, with regression tests that keep real timeout attempts marked aborted.

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

Yes for the PR-introduced regression by source inspection: ordinary timeouts call abortRun(true), which sets both aborted and timedOut, so the proposed guard skips timeout compaction. No live proof was provided for the contributor's claimed Control UI stop scenario.

Is this the best way to solve the issue?

No. The change should distinguish user-initiated aborts from internal timeout aborts instead of blocking all aborted timeout attempts from timeout recovery.

Full review comments:

  • [P1] Preserve timeout compaction for internal timeouts — src/agents/pi-embedded-runner/run.ts:1560
    The runner's own timeout path calls abortRun(true), and that sets both aborted = true and timedOut = true, so this guard excludes ordinary internal LLM timeouts from timeout-compaction recovery. The test changes avoid that by removing aborted from normal timeout fixtures, but real timeout attempts keep it, so high-context timeouts will fall through instead of compacting.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

What I checked:

  • PR diff changes the compaction gate: The PR changes the timeout-compaction condition to timedOut && !aborted && ..., and removes aborted: true from the normal retry-cap timeout fixtures. (src/agents/pi-embedded-runner/run.ts:1560, 9c503bb6c01a)
  • Current main compacts on timed-out high-context attempts: Current main's timeout-compaction block runs when timedOut is true and the attempt was not already in compaction or tool execution timeout. (src/agents/pi-embedded-runner/run.ts:1560, 9924fff1afc7)
  • Real timeout attempts also set aborted: The internal timeout path calls abortRun(true), and abortRun(true) sets both aborted = true and timedOut = true, so !aborted excludes normal runner timeouts. (src/agents/pi-embedded-runner/run/attempt.ts:2613, 9924fff1afc7)
  • Existing regression coverage codifies aborted timeout compaction: Current main has a focused test named still attempts compaction for timed-out attempts that set aborted, plus retry-cap tests where timed-out attempts include aborted: true. (src/agents/pi-embedded-runner/run.timeout-triggered-compaction.test.ts:368, 9924fff1afc7)
  • History points to the timeout-compaction block and tests: Blame for the timeout-compaction condition, abort timeout flagging, and aborted-timeout regression tests all points to commit cc84606 in the available local history. (src/agents/pi-embedded-runner/run.ts:1557, cc84606946eb)
  • Real behavior proof is absent: The live PR body is empty and comments contain only a ClawSweeper status placeholder, with no screenshot, recording, logs, terminal output, or linked artifact showing the after-fix Control UI stop behavior. (9c503bb6c01a)

Likely related people:

  • Shakker: Available blame for the timeout-compaction block, abort timeout flagging, and the aborted-timeout tests points to the same commit authored by Shakker; local history for these paths is otherwise sparse. (role: available-history area contributor; confidence: medium; commits: cc84606946eb; files: src/agents/pi-embedded-runner/run.ts, src/agents/pi-embedded-runner/run/attempt.ts, src/agents/pi-embedded-runner/run.timeout-triggered-compaction.test.ts)

Remaining risk / open question:

  • The PR has no real after-fix proof for the claimed Control UI stop flow.
  • The correct guard likely needs to distinguish caller/user aborts from internal timeout aborts; using the generic aborted flag conflates both paths.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 9924fff1afc7.

Re-review progress:

@lykeion-dev
lykeion-dev marked this pull request as draft May 12, 2026 14:28
@lykeion-dev
lykeion-dev deleted the fix/skip-timeout-compaction-on-abort branch May 12, 2026 15:37
lykeion-dev added a commit to lykeion-dev/openclaw--rev that referenced this pull request May 14, 2026
When the user presses the stop button in the Control UI, the model
request times out. Previously, if context token usage exceeded 65%,
the timeout compaction mechanism would fire even though the run was
intentionally aborted — causing unnecessary compaction at an
inappropriate time.

Add !externalAbort check to the timeout compaction condition so that
user-initiated stops skip compaction entirely.

Unlike the original PR openclaw#80746 which used !aborted (incorrectly skipping
internal timeout compaction too), this fix uses !externalAbort which is
only set for user-initiated stops via the abort signal handler.

Also updates the existing test to explicitly set externalAbort: false
for the internal timeout case, and adds a new test for the user abort
case.

CHANGELOG: Added to Unreleased section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS triage: blank-template Candidate: PR template appears mostly untouched. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant