Skip to content

fix(compaction): preflight compaction uses configured compaction timeout instead of reply operation abort signal#95580

Closed
xydt-tanshanshan wants to merge 3 commits into
openclaw:mainfrom
xydt-tanshanshan:fix/preflight-compaction-abort-95553
Closed

fix(compaction): preflight compaction uses configured compaction timeout instead of reply operation abort signal#95580
xydt-tanshanshan wants to merge 3 commits into
openclaw:mainfrom
xydt-tanshanshan:fix/preflight-compaction-abort-95553

Conversation

@xydt-tanshanshan

@xydt-tanshanshan xydt-tanshanshan commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Preflight (budget-triggered) compaction received replyOperation.abortSignal, causing compactWithSafetyTimeout's Promise.race to kill slow compactions at ~60s — the reply lifecycle timeout — ignoring compaction.timeoutSeconds. The fix introduces a cancellation-only signal that forwards explicit user abort and gateway restart but filters out the lifecycle timeout, letting compactWithSafetyTimeout be the sole timeout owner.

  • Problem: replyOperation.abortSignal fires on three triggers: (1) user abort, (2) gateway restart, (3) lifecycle timeout at ~60s. Preflight compaction should cancel on (1) and (2) but not on (3), yet all three fire the same AbortController. Slow compactions on large sessions never complete.
  • Solution: Create createPreflightCompactionCancelSignal(replyOperation) that inspects abortSignal.reason.name: propagate for user abort / restart, suppress for TimeoutError (lifecycle timeout). compactWithSafetyTimeout handles the 180s default timeout.
  • What changed: src/auto-reply/reply/agent-runner-memory.ts — +17 lines: new createPreflightCompactionCancelSignal helper + use it at the compaction call site. src/auto-reply/reply/agent-runner-memory.test.ts — +79 lines: 3 tests (1 integration + 2 direct unit tests).
  • What did NOT change: Memory flush path's runEmbeddedAgent still uses replyOperation.abortSignal directly. Non-preflight compaction paths. compactWithSafetyTimeout core logic. resolveCompactionTimeoutMs.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Motivation

OpenClaw runs two compaction paths with different effective timeouts:

Path Trigger Effective timeout Source
Overflow recovery trigger=overflow ~180s resolveCompactionTimeoutMs(cfg) via compactWithSafetyTimeout
Preflight / budget trigger=budget ~60s replyOperation.abortSignal (lifecycle timeout, NOT config-derived)

The preflight path fires before every turn where totalTokens >= contextWindow - reserveTokensFloor - softThresholdTokens. On backends where summarizing a large context takes >60s, preflight compaction can never complete. The reply lifecycle timeout (TimeoutError) from src/gateway/chat-abort.ts aborts the controller, and compactWithSafetyTimeout's Promise.race kills the compaction.

The issue reporter observed: 24 of 26 incomplete compactions clustered at exactly 60–61s, while successful compactions had median duration 278s.

Real behavior proof

  • Behavior addressed: Preflight compaction cancel signal no longer carries the reply lifecycle timeout, allowing compactions to run up to the configured compaction.timeoutSeconds.
  • Real environment tested: Linux x86_64, Node 22.19+, vitest
  • Exact steps or command run after this patch:
node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-memory.test.ts --run
  • Evidence after fix:
$ node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-memory.test.ts --run
 Tests  49 passed (49)
Scenario abortSignal.reason.name Cancel signal outcome
User abort AbortError ✅ Cancelled
Gateway restart AbortError (code: OPENCLAW_RESTART_ABORT) ✅ Cancelled
Lifecycle timeout (~60s) TimeoutError ❌ Not cancelled — compaction continues to config timeout
  • Observed result after fix:

    1. Preflight compaction receives a new cancel signal (not raw replyOperation.abortSignal) — verified by reference inequality test
    2. User abort propagates through the cancel signal — verified by unit test
    3. Lifecycle TimeoutError (reason name) does not propagate — verified by unit test
    4. All 46 existing tests in agent-runner-memory.test.ts continue to pass
  • What was not tested: Live end-to-end verification with slow compaction backends (vLLM/Qwen). Unit tests prove the signal filtering logic; real-world 60s→278s completion improvement requires a slow-backend deployment.

Root Cause

Provenance: introduced by commit 5374c7a8a (Peter Steinberger, 2026-05-30) which created both compactWithSafetyTimeout (with Promise.race against external abort) and createReplyOperation (with AbortController). The preflight path connected them via commit 280d1cb97 (Vincent Koc, 2026-06-09).

Data flow: agent-runner.tsrunPreflightCompactionIfNeededcompactEmbeddedAgentSessioncompactWithSafetyTimeoutPromise.race([compactPromise, externalAbortPromise]). The lifecycle timeout fires via src/gateway/server-maintenance.ts:284 (setInterval 60s) → chat-abort.ts:476 (abort("timeout")) → replyOperation.abortSignalPromise.race kills compaction.

Confidence: clear — source inspection confirms the signal chain, unit tests validate the filtering logic.

User-visible / Behavior Changes

  • Preflight compaction on slow backends can now complete within the configured compaction.timeoutSeconds (default 180s) instead of being killed at ~60s by the lifecycle timeout.
  • User abort and gateway restart still cancel preflight compaction.
  • No config changes required.

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Human Verification

  • Verified scenarios: User abort propagates through cancel signal; lifecycle TimeoutError is filtered out; existing 46 tests pass
  • Edge cases checked: Pre-aborted signal (already aborted before createPreflightCompactionCancelSignal is called); abort reason inspection
  • What you did NOT verify: Live slow-backend deployment showing 60s→278s completion improvement

Compatibility / Migration

  • Backward compatible? Yes — existing config keys unchanged
  • Config/env changes? No
  • Migration needed? No

Best-fix Verdict

  • Best fix: Yes. The fix identifies the correct boundary — distinguishing lifecycle timeout from explicit cancellation via abortSignal.reason.name — and creates a per-call cancellation-only signal. This preserves the explicit cancel contract (stop/restart) while removing the lifecycle timeout race. compactWithSafetyTimeout is the sole timeout owner.
  • Refactor needed: No.
  • Alternative considered: Passing no abort signal at all. Rejected — loses explicit stop/restart cancellation, which the review specifically asked to preserve. Composing with AbortSignal.any + AbortSignal.timeout. Rejected — duplicates timeout ownership and the reply signal can still win first.

AI Assistance

  • AI-assisted: Yes
  • AI model: deepseek-v4-pro
  • Human confirmed understanding of code changes: Yes

Risks and Mitigations

  • Highest risk area: The abortSignal.reason inspection assumes TimeoutError name reliably identifies lifecycle timeout vs other timeout errors. Validated against chat-abort.ts:476 which creates reason.name = "TimeoutError".
  • Mitigation: The filter is narrow — only TimeoutError is suppressed. Any other Error (including provider-level timeouts) propagates through and cancels compaction.

@clawsweeper

clawsweeper Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 21, 2026, 10:28 PM ET / 02:28 UTC.

Summary
This PR adds a derived cancellation-only signal for budget/preflight compaction, passes that signal into compactEmbeddedAgentSession, and adds unit coverage for timeout filtering and explicit abort propagation.

PR surface: Source +52, Tests +125. Total +177 across 2 files.

Reproducibility: yes. at source level: current main and v2026.6.9 pass the raw reply-operation abort signal into required budget/preflight compaction, while compactWithSafetyTimeout races caller aborts before the configured timeout. I did not live-reproduce the reporter's slow vLLM/Qwen deployment.

Review metrics: 1 noteworthy metric.

  • Cancellation poller: 1 added. The new interval sits outside compactWithSafetyTimeout's cleanup lifecycle, so maintainers should verify it is cleared before merge.

Stored data model
Persistent data-model change detected: serialized state: src/auto-reply/reply/agent-runner-memory.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #95553
Summary: This PR is a candidate fix for the canonical preflight/budget compaction abort-scope issue, with competing open fixes and adjacent broader compaction-timeout work still active.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦪 silver shellfish
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Wrap the derived cancellation cleanup in a finally and cover a rejected compact call after a filtered TimeoutError.
  • [P1] Add redacted real slow-preflight proof showing compaction continues past the old reply lifecycle abort window.
  • [P1] Let maintainers choose the canonical fix path for the linked preflight compaction issue.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body provides Vitest/unit output only and explicitly says live slow-backend behavior was not tested, so it still needs redacted logs, terminal output, or a linked artifact from a real slow preflight run before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] If compactEmbeddedAgentSession rejects after a filtered lifecycle TimeoutError, the helper-owned 500ms poller can remain live because cleanup is after the await instead of in a finally.
  • [P1] The supplied after-fix proof is Vitest/unit output only and explicitly does not show a real slow preflight compaction completing past the old reply lifecycle abort window.
  • [P1] There are multiple open candidate fixes for Bug: preflight (budget-triggered) compaction hard-capped at ~60s, ignores compaction.timeoutSeconds #95553, so maintainers still need to choose the canonical preflight cancellation contract.

Maintainer options:

  1. Make Cleanup Exception-Safe (recommended)
    Wrap the derived cancellation signal around compactEmbeddedAgentSession with a finally so helper cleanup runs on resolved, rejected, aborted, and timeout paths, with regression coverage for a rejected compact call after a filtered TimeoutError.
  2. Require Slow-Preflight Proof
    Ask for redacted runtime logs, terminal output, or a linked artifact showing a real slow preflight compaction continuing past the old reply lifecycle abort window.
  3. Choose One Candidate Fix
    Pause this branch until maintainers settle whether this PR, another open candidate, or a narrower replacement should be the canonical implementation for the linked issue.

Next step before merge

  • [P1] Human review remains because the PR needs contributor-owned real slow-preflight proof and a maintainer decision on the canonical cancellation contract before merge.

Security
Cleared: The diff only changes TypeScript abort-signal handling and unit tests; it adds no dependency, workflow, package, credential, network, or secret-handling surface.

Review findings

  • [P2] Clean up the derived signal in a finally — src/auto-reply/reply/agent-runner-memory.ts:1034
Review details

Best possible solution:

Adopt one lifecycle-owned preflight cancellation contract that ignores normal reply lifecycle timeout, still propagates explicit user abort and restart cancellation, cleans up helper state on every compact settlement path, and is backed by redacted real slow-preflight proof.

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

Yes, at source level: current main and v2026.6.9 pass the raw reply-operation abort signal into required budget/preflight compaction, while compactWithSafetyTimeout races caller aborts before the configured timeout. I did not live-reproduce the reporter's slow vLLM/Qwen deployment.

Is this the best way to solve the issue?

No as written. The derived cancellation signal is the right direction, but cleanup needs to be exception-safe and the branch still needs real slow-preflight proof plus a maintainer choice among competing candidate fixes.

Full review comments:

  • [P2] Clean up the derived signal in a finally — src/auto-reply/reply/agent-runner-memory.ts:1034
    The helper cleanup currently runs only after compactEmbeddedAgentSession resolves. If that call rejects after a filtered lifecycle TimeoutError, the helper-owned 500ms poller can stay live; wrap the compact await in try/finally so cleanup runs on success, failure, abort, and timeout paths.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ad304e790d0c.

Label changes

Label justifications:

  • P1: The PR targets a real large-session compaction regression that can block agent turns and hold active session work in deployed workflows.
  • merge-risk: 🚨 session-state: The diff changes required preflight compaction while session context is near overflow, where stale or missed cancellation affects active transcript and session state.
  • merge-risk: 🚨 availability: An uncleared helper poller or wrong cancellation contract can leave repeated slow preflight work consuming runtime resources before user turns proceed.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides Vitest/unit output only and explicitly says live slow-backend behavior was not tested, so it still needs redacted logs, terminal output, or a linked artifact from a real slow preflight run before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +52, Tests +125. Total +177 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 53 1 +52
Tests 1 125 0 +125
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 178 1 +177

What I checked:

Likely related people:

  • vincentkoc: Current blame and recent history carry the affected preflight compaction call and compaction safety wrapper through the current main snapshot; commit 280d1cb also touched the preflight compaction notice path. (role: recent current-source contributor; confidence: medium; commits: 280d1cb977c4, 8c0767ffa4de; files: src/auto-reply/reply/agent-runner-memory.ts, src/agents/embedded-agent-runner/compaction-safety-timeout.ts)
  • jared596: PR Trigger preflight compaction from transcript estimates when usage is stale #49479 expanded runPreflightCompactionIfNeeded around transcript estimates, which is central to the budget/preflight trigger path this PR changes. (role: preflight compaction feature contributor; confidence: high; commits: c6d8318d07f5; files: src/auto-reply/reply/agent-runner-memory.ts, src/auto-reply/reply/agent-runner.ts)
  • wangmiao0668000666: PR fix(compaction): lower default timeout from 900s to 180s, preserve explicit config #91361 changed the default compaction timeout while preserving explicit timeoutSeconds, directly relevant to the timeout semantics this PR relies on. (role: timeout contract contributor; confidence: high; commits: bb6e47729cf8; files: src/agents/embedded-agent-runner/compaction-safety-timeout.ts, docs/gateway/config-agents.md, src/config/schema.help.ts)
  • dutifulbob: The merged reply lifecycle work in Auto-reply: unify reply lifecycle across stop, rotation, and restart #61267 is relevant to which reply-operation aborts should still cancel preflight compaction. (role: reply lifecycle contributor; confidence: medium; commits: 3f6840230b86; files: src/auto-reply/reply/reply-run-registry.ts, src/auto-reply/reply/agent-runner.ts, src/auto-reply/reply/agent-runner-memory.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 21, 2026
@xydt-tanshanshan
xydt-tanshanshan force-pushed the fix/preflight-compaction-abort-95553 branch from 07f41c0 to aaeb512 Compare June 21, 2026 15:27
@xydt-tanshanshan

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 21, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@xydt-tanshanshan
xydt-tanshanshan force-pushed the fix/preflight-compaction-abort-95553 branch from aaeb512 to a078f14 Compare June 21, 2026 15:50
@clawsweeper clawsweeper Bot added status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 21, 2026
@xydt-tanshanshan

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 21, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. and removed status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 21, 2026
@xydt-tanshanshan
xydt-tanshanshan force-pushed the fix/preflight-compaction-abort-95553 branch from a078f14 to 38bd522 Compare June 21, 2026 16:12
@xydt-tanshanshan

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 21, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@xydt-tanshanshan
xydt-tanshanshan force-pushed the fix/preflight-compaction-abort-95553 branch from 38bd522 to 6cde290 Compare June 21, 2026 16:26
@xydt-tanshanshan

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 21, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@xydt-tanshanshan
xydt-tanshanshan force-pushed the fix/preflight-compaction-abort-95553 branch 2 times, most recently from 39c1676 to 59ddd5f Compare June 22, 2026 02:09
@xydt-tanshanshan

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 22, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jun 22, 2026
…action

Preflight compaction received replyOperation.abortSignal (~60s lifecycle
timeout) via compactWithSafetyTimeout's Promise.race, causing slow
compactions to be killed before the configured compaction.timeoutSeconds.

Create createPreflightCompactionCancelSignal with three-layer protection:
1. abortSignal.reason inspection: propagate explicit cancel, filter
   TimeoutError (lifecycle) through a one-shot event listener
2. When TimeoutError is filtered, start a polling interval on
   replyOperation.result (set only on explicit user/restart abort)
3. Check replyOperation.result immediately after construction for the
   already-aborted case

compactWithSafetyTimeout remains the sole timeout owner.

Related to openclaw#95553
@xydt-tanshanshan
xydt-tanshanshan force-pushed the fix/preflight-compaction-abort-95553 branch from 59ddd5f to f2841d0 Compare June 22, 2026 03:13
@xydt-tanshanshan
xydt-tanshanshan requested a review from a team as a code owner June 22, 2026 03:13
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Guard

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

Changed files:

  • pnpm-lock.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile, shrinkwrap, or workspace dependency policy changes are present.
  • Treat package-lock.json and npm-shrinkwrap.json diffs as security-review surfaces.
  • 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.

@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency graph changes are blocked

OpenClaw does not accept dependency graph changes through PRs unless a repository admin or security explicitly authorizes the current head SHA. Dependency updates are generated internally by maintainers so external PRs cannot change the resolved graph.

Detected dependency graph changes:

  • pnpm-lock.yaml changed.

To remove lockfile changes, restore them from the target branch:

git fetch origin
git checkout 'origin/main' -- 'pnpm-lock.yaml'
git commit -m 'chore: remove dependency lockfile change'
git push

If this PR intentionally needs a dependency graph change, ask a repository admin or member of @openclaw/openclaw-secops to comment:

/allow-dependencies-change

The action will approve the current head SHA (f2841d0ee392cf5bbb216e817c35e8300d2644ad) when it reruns. A later push requires a fresh approval.

wangmiao0668000666 added a commit to wangmiao0668000666/openclaw that referenced this pull request Jun 22, 2026
…law#95553)

Adds a user-facing config gate to disable preflight (budget-triggered)
compaction. When compaction.preflight.enabled === false, the pre-turn
threshold check in runPreflightCompactionIfNeeded short-circuits to the
existing session entry, so subsequent turns fall through to overflow
recovery (which already honors compaction.timeoutSeconds with a 15min
budget).

The check is '=== false' against the literal value, so an unset key
preserves the existing default-on behavior — the fix is strictly
additive and does not change shipped behavior for any current user.

This complements the four open PRs (openclaw#95561, openclaw#95563, openclaw#95580, openclaw#95590)
that are all working on the abortSignal source for the preflight
path. None of those PRs addresses the user-facing config dimension
that the issue explicitly requests.

Changes:
- src/config/types.agent-defaults.ts: new AgentCompactionPreflightConfig
  type with optional enabled boolean
- src/config/zod-schema.agent-defaults.ts: zod schema with strict mode
- src/config/schema.help.ts + schema.labels.ts: help text + label
- src/auto-reply/reply/agent-runner-memory.ts: 6-line early return in
  runPreflightCompactionIfNeeded, placed after isHeartbeat/isCli and
  before codex runtime so the gate is the only OpenClaw-specific path
  affected
- src/auto-reply/reply/agent-runner-memory.test.ts: 1 new test
  (skips preflight compaction when enabled === false) using the
  same test fixture pattern as adjacent tests
- scripts/repro/issue-95553-preflight-disabled-gate.mts: standalone
  real-environment proof that exercises the production gate

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

Labels

dependencies-changed PR changes dependency-related files extensions: codex merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant