Skip to content

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

Closed
lykeion-dev wants to merge 2263 commits into
openclaw:mainfrom
lykeion-dev:fix/skip-timeout-compaction-on-abort-5.9
Closed

fix: skip timeout compaction when run was aborted by user#81088
lykeion-dev wants to merge 2263 commits into
openclaw:mainfrom
lykeion-dev:fix/skip-timeout-compaction-on-abort-5.9

Conversation

@lykeion-dev

Copy link
Copy Markdown

Summary

Rebased version of #80746 on the 2026.5.9 release branch (original was based on 5.7).

Problem

When the user presses the Stop button in the Control UI, the run is aborted. Previously, if context token usage exceeded 65%, the timeout compaction mechanism would still fire — causing unnecessary compaction at an inappropriate time.

Fix

Add !externalAbort guard to the timeout compaction condition in src/agents/pi-embedded-runner/run.ts.

Why externalAbort instead of aborted:

  • aborted is set to true for BOTH user-initiated stops AND internal LLM timeouts (via abortRun(true))
  • Using !aborted would incorrectly skip compaction for genuine provider timeouts that need recovery
  • externalAbort is ONLY set when the user presses Stop (via the onAbort handler on params.abortSignal)

Changes

  • src/agents/pi-embedded-runner/run.ts: Add !externalAbort to both timeout compaction conditions
  • src/agents/pi-embedded-runner/run.timeout-triggered-compaction.test.ts: Update existing test to explicitly set externalAbort: false, add new test for user abort case
  • CHANGELOG.md: Added to Unreleased section

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 12, 2026
@clawsweeper

clawsweeper Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR adds an externalAbort guard to timeout-triggered compaction, updates timeout-compaction coverage, and currently carries a large stale branch diff across changelog, workflows, dependencies, apps, docs, and plugins.

Reproducibility: yes. by source inspection: current main can enter timeout compaction on a timed-out user abort because the compaction gate ignores externalAbort. The PR-introduced payload regression is also source-reproducible from the head file contents and existing payload helpers.

Real behavior proof
Needs real behavior proof before merge: The PR body/comments contain no after-fix Control UI Stop proof from a real OpenClaw setup; the contributor should add redacted screenshots, recording, terminal output, logs, or a linked artifact and update the PR body so ClawSweeper re-reviews, or ask a maintainer to comment @clawsweeper re-review.

Next step before merge
Protected security label, missing external contributor proof, and branch-wide stale changes require contributor/maintainer cleanup rather than an automated repair lane.

Security
Needs attention: The PR carries security-sensitive workflow and dependency churn unrelated to the timeout fix, so the branch needs pruning or explicit maintainer security review before merge.

Review findings

  • [P1] Rebase away stale branch-wide reversions — CHANGELOG.md:4
  • [P2] Preserve timeout payload synthesis — src/agents/pi-embedded-runner/run.ts:2376
Review details

Best possible solution:

Rebase onto current main, drop unrelated history, guard only timeout-triggered compaction with externalAbort, preserve timeout error payload synthesis, add focused regression coverage, and attach redacted real Control UI Stop proof.

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

Yes by source inspection: current main can enter timeout compaction on a timed-out user abort because the compaction gate ignores externalAbort. The PR-introduced payload regression is also source-reproducible from the head file contents and existing payload helpers.

Is this the best way to solve the issue?

No. externalAbort is the right discriminator for the compaction gate, but applying it to timedOutDuringPrompt suppresses the timeout error payload, and the branch must be narrowed before it is reviewable.

Full review comments:

  • [P1] Rebase away stale branch-wide reversions — CHANGELOG.md:4
    The PR head is not a narrow timeout fix: comparing it to current main replaces the 2026.5.14 changelog with a small Unreleased section, and the API reports 5,205 changed files. Merging this branch as-is would drop current release notes and broad current-main changes; rebase onto current main and keep only the focused runner/test diff.
    Confidence: 0.96
  • [P2] Preserve timeout payload synthesis — src/agents/pi-embedded-runner/run.ts:2376
    This guard makes timedOutDuringPrompt false for the new timedOut/aborted/externalAbort case. Since the payload builder has no timeout fallback and incomplete-turn synthesis returns null for aborted or timed-out attempts, the run can fall through without the timeout error payload the new test expects.
    Confidence: 0.93

Overall correctness: patch is incorrect
Overall confidence: 0.93

Security concerns:

  • [high] Remove unrelated release and dependency churn — .github/workflows/openclaw-release-publish.yml:53
    The branch touches release workflows, CodeQL configuration, Docker/package surfaces, and many dependency files while the stated fix only needs agent runner/test changes. The current-main comparison also shows release workflow downgrades/removals, which is supply-chain sensitive if merged accidentally.
    Confidence: 0.91

What I checked:

  • Live PR metadata: GitHub API reports the PR is open, not draft, mergeable=false, head 17b3165, with 5,205 changed files, 160,383 additions, 152,506 deletions, the protected security label, and triage: needs-real-behavior-proof. (17b3165a974d)
  • Focused compaction change: The PR head adds && !externalAbort to the timeout-triggered compaction condition, which is the right discriminator for user-initiated stops versus internal provider timeouts. (src/agents/pi-embedded-runner/run.ts:1450, 17b3165a974d)
  • Current main behavior: Current main still runs timeout-triggered compaction for timedOut && !timedOutDuringCompaction && !timedOutDuringToolExecution without checking externalAbort, so the central bug claim is source-reproducible. (src/agents/pi-embedded-runner/run.ts:1569, 99a6b1c5a886)
  • Timeout payload regression: The PR also adds !externalAbort to timedOutDuringPrompt; with timedOut=true, aborted=true, externalAbort=true, and no assistant text, this bypasses the explicit timeout error payload path. (src/agents/pi-embedded-runner/run.ts:2376, 17b3165a974d)
  • No fallback timeout payload: resolveIncompleteTurnPayloadText returns null when the attempt is aborted or timed out, and buildEmbeddedRunPayloads builds payloads from assistant/tool content rather than timeout state, so the guarded timeout path is required for the added test expectation. (src/agents/pi-embedded-runner/run/incomplete-turn.ts:237, 17b3165a974d)
  • Stale branch comparison: Comparing the PR head to current main shows the branch would replace the current 2026.5.14 changelog with a small Unreleased section, confirming this is not a narrow mergeable diff against main. (CHANGELOG.md:4, 17b3165a974d)

Likely related people:

  • vincentkoc: Available current-main blame points the timeout compaction gate, timeout payload synthesis, and abort flag plumbing at the current snapshot, and recent path history shows additional runner/attempt maintenance by this contributor. (role: recent area contributor; confidence: medium; commits: 278e3eabf2, a47132734ba2, af3d9333aa8a; files: src/agents/pi-embedded-runner/run.ts, src/agents/pi-embedded-runner/run/attempt.ts)
  • steipete: Recent GitHub path history for timeout-compaction tests and timeout policy includes several focused commits in this area. (role: timeout-compaction test and policy contributor; confidence: medium; commits: 908bb0f1c74e, f3e8a8a3195a, d9dc75774bcb; files: src/agents/pi-embedded-runner/run.timeout-triggered-compaction.test.ts, src/agents/pi-embedded-runner/run.ts)
  • doedewaldt: Recent run-loop history includes explicit timeout error and partial-fragment handling commits that are directly related to the PR's timeout payload path. (role: recent timeout payload contributor; confidence: medium; commits: db57da50c994, 18f4a2d98723; files: src/agents/pi-embedded-runner/run.ts)

Remaining risk / open question:

  • No after-fix Control UI Stop proof is present, so the claimed user-facing behavior has not been demonstrated in a real setup.
  • The branch is far wider than the described fix and includes security-sensitive workflow and dependency surfaces that need pruning or separate review.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 99a6b1c5a886.

Re-review progress:

@lykeion-dev lykeion-dev changed the title fix: skip timeout compaction when run was aborted by user (5.9 fork) fix: skip timeout compaction when run was aborted by user May 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Changes Detected

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/acpx/package.json
  • extensions/alibaba/package.json
  • extensions/amazon-bedrock-mantle/package.json
  • extensions/amazon-bedrock/package.json
  • extensions/anthropic-vertex/package.json
  • extensions/anthropic/package.json
  • extensions/arcee/package.json
  • extensions/azure-speech/package.json
  • extensions/bluebubbles/package.json
  • extensions/bonjour/package.json
  • extensions/brave/package.json
  • extensions/browser/package.json
  • extensions/byteplus/package.json
  • extensions/canvas/package.json
  • extensions/cerebras/package.json
  • extensions/chutes/package.json
  • extensions/cloudflare-ai-gateway/package.json
  • extensions/codex/package.json
  • extensions/comfy/package.json
  • extensions/copilot-proxy/package.json
  • extensions/deepgram/package.json
  • extensions/deepinfra/package.json
  • extensions/deepseek/package.json
  • extensions/diagnostics-otel/package.json
  • extensions/diagnostics-prometheus/package.json
  • 98 additional dependency-related files not shown

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile or workspace dependency policy changes are present.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android app: ios App: ios app: macos App: macos channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: irc channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: qa-channel Channel integration: qa-channel channel: qqbot channel: signal Channel integration: signal channel: slack Channel integration: slack channel: synology-chat channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: twitch Channel integration: twitch channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: acpx extensions: amazon-bedrock extensions: anthropic extensions: anthropic-vertex extensions: arcee extensions: brave extensions: byteplus extensions: cerebras extensions: chutes extensions: cloudflare-ai-gateway extensions: codex extensions: copilot-proxy Extension: copilot-proxy extensions: deepinfra extensions: deepseek extensions: device-pair extensions: diagnostics-otel Extension: diagnostics-otel extensions: diagnostics-prometheus extensions: diffs extensions: duckduckgo extensions: elevenlabs extensions: fal extensions: firecrawl extensions: github-copilot extensions: google extensions: gradium extensions: huggingface extensions: inworld Extension: inworld extensions: kilocode extensions: kimi-coding extensions: litellm extensions: llm-task Extension: llm-task extensions: lmstudio extensions: lobster Extension: lobster extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb extensions: memory-wiki extensions: microsoft extensions: minimax extensions: mistral extensions: moonshot extensions: nvidia extensions: oc-path extensions: open-prose Extension: open-prose extensions: openai extensions: phone-control extensions: qa-lab extensions: qianfan extensions: senseaudio extensions: stepfun extensions: synthetic extensions: tavily extensions: tencent extensions: together extensions: tokenjuice Changes to the bundled tokenjuice extension extensions: tts-local-cli extensions: venice extensions: vercel-ai-gateway extensions: volcengine extensions: webhooks extensions: xiaomi gateway Gateway runtime plugin: azure-speech Azure Speech plugin plugin: bonjour Plugin integration: bonjour plugin: file-transfer plugin: google-meet plugin: migrate-claude plugin: migrate-hermes scripts Repository scripts security Security documentation size: XL 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.