Skip to content

fix(agents): handle preflight compaction no-op budgets - #86709

Merged
mcaxtr merged 3 commits into
mainfrom
fix/preflight-compaction-noop
May 26, 2026
Merged

mcaxtr merged 3 commits into
mainfrom
fix/preflight-compaction-noop

Conversation

@mcaxtr

@mcaxtr mcaxtr commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Treat ok: true, compacted: false preflight compaction results as successful no-ops instead of failing the reply path.
  • Pass the caller-resolved context budget from src/auto-reply/reply/agent-runner-memory.ts into runtime compaction so the compactor evaluates the same budget that triggered preflight.
  • Clamp caller-provided compaction budgets to the selected compaction model's resolved context window in src/agents/pi-embedded-runner/compact.ts, so an active conversation model cannot overstate the capacity of a smaller compaction model.
  • Added focused coverage for no-op preflight behavior, budget forwarding, and compaction-model budget clamping.

Verification

  • git diff --check
  • pnpm tsgo:core
  • pnpm check:test-types

Real behavior proof

Behavior addressed: preflight compaction no longer fails a successful no-op result, while runtime compaction still receives and clamps the caller budget safely.

Real environment tested: local OpenClaw checkout on branch fix/preflight-compaction-noop.

Exact steps or command run after this patch: git diff --check; pnpm tsgo:core.

Evidence after fix: whitespace check passed; core TypeScript lane passed.

Observed result after fix: branch typechecks with the new budget-forwarding and budget-clamping paths.

What was not tested: focused Vitest completion; local Vitest processes remained CPU-bound with no output and were killed after bounded waits.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels May 26, 2026
@clawsweeper

clawsweeper Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed May 25, 2026, 10:31 PM ET / 02:31 UTC.

Summary
The PR accepts successful no-op preflight compaction results, forwards caller-resolved context budgets into compaction, clamps compaction budgets to the selected compaction model, and adds focused tests.

PR surface: Source +28, Tests +113. Total +141 across 6 files.

Reproducibility: yes. from source: current main treats an ok but non-compacted preflight result as failure, and the PR adds a focused test for that path. I did not run the runtime path because this review is read-only.

Review metrics: 1 noteworthy metric.

  • Compaction decision surfaces: 3 behavior decisions changed. The PR changes no-op preflight handling, direct compaction budget selection, and queued compaction budget selection, which are compatibility-sensitive before merge.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🌊 off-meta tidepool
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

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

Risk before merge

  • Merging changes how existing sessions handle ok-but-not-compacted preflight results and can lower compaction budgets when the compaction model is smaller than the active conversation model, so maintainers should explicitly accept that upgrade behavior.

Maintainer options:

  1. Accept the compatibility change after review (recommended)
    A maintainer can merge once they confirm the no-op success semantics and smaller compaction-model clamp are intentional for upgraded sessions.
  2. Ask for focused upgrade proof first
    Before merge, require focused proof that an existing over-budget session continues safely through the no-op and budget-clamp paths.
  3. Pause if the semantics need a separate decision
    If no-op compaction should remain a hard preflight failure or active-model budgets should dominate, split that product decision from this mechanical fix.

Next step before merge
Protected maintainer handling plus compatibility-sensitive session budget semantics require maintainer review rather than an automated repair lane.

Security
Cleared: The diff stays within agent compaction code and tests and does not introduce dependency, CI, credential, release, or code-execution supply-chain changes.

Review details

Best possible solution:

Land the patch after maintainer review confirms that no-op success and compaction-model budget clamping are the intended behavior for existing agent sessions.

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

Yes from source: current main treats an ok but non-compacted preflight result as failure, and the PR adds a focused test for that path. I did not run the runtime path because this review is read-only.

Is this the best way to solve the issue?

Yes, pending maintainer compatibility review: accepting ok non-compacted results and clamping to the compaction model is a narrow fix in the affected agent memory and compaction code, not a new product surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 34d862d45d68.

Label changes

Label changes:

  • add merge-risk: 🚨 session-state: The changed paths decide whether and how conversation context is compacted before a reply, so mistakes can affect session continuity.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority agent compaction bug fix with limited but real blast radius for long-running reply sessions.
  • merge-risk: 🚨 compatibility: The PR changes existing preflight failure semantics and clamps caller budgets against the compaction model, which can affect upgraded sessions.
  • merge-risk: 🚨 session-state: The changed paths decide whether and how conversation context is compacted before a reply, so mistakes can affect session continuity.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor real-behavior proof gate does not apply to this maintainer-labeled member PR; the PR body still records local typecheck and diff-check proof, with focused Vitest completion missing.
Evidence reviewed

PR surface:

Source +28, Tests +113. Total +141 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 74 46 +28
Tests 2 130 17 +113
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 204 63 +141

Acceptance criteria:

  • git diff --check
  • pnpm tsgo:core
  • pnpm check:test-types
  • node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-memory.test.ts src/agents/pi-embedded-runner/compact.hooks.test.ts

What I checked:

  • Repository policy applied: The full root policy and the scoped agents policy were read; the root policy treats agent session/context paths and fallback behavior as compatibility-sensitive, and the scoped agents policy informed the validation expectations for agent tests. (AGENTS.md:1, 34d862d45d68)
  • Current main still fails successful no-op compaction: Current main throws when preflight compaction returns ok but compacted is false, so the PR is not obsolete on main. (src/auto-reply/reply/agent-runner-memory.ts:821, 34d862d45d68)
  • PR accepts no-op success and forwards budget: The PR passes contextTokenBudget into compactEmbeddedPiSession, fails only when result.ok is false, and returns without compaction side effects when result.compacted is false. (src/auto-reply/reply/agent-runner-memory.ts:817, 84400c92f3b2)
  • PR clamps runtime compaction budget: Direct compaction normalizes the caller budget and caps it to the compaction model's resolved context window before passing modelContextWindowTokens to the tool runtime. (src/agents/pi-embedded-runner/compact.ts:700, 84400c92f3b2)
  • PR clamps queued compaction budget: Queued compaction now resolves the compaction target model, normalizes the caller contextTokenBudget, and passes the min of caller and compaction-model budgets into harness and context-engine compaction. (src/agents/pi-embedded-runner/compact.queued.ts:115, 84400c92f3b2)
  • Focused regression coverage added: The PR adds tests for successful no-op preflight behavior, caller budget forwarding, direct budget clamping, and queued budget clamping. (src/auto-reply/reply/agent-runner-memory.test.ts:946, 84400c92f3b2)

Likely related people:

  • Peter Steinberger: Blame points the current main preflight and compaction budget code to da831e2, and history also shows prior contextTokens cap work in the same compaction path. (role: current behavior and adjacent budget-history owner; confidence: high; commits: da831e2b8aef, 537c97cce96d; files: src/auto-reply/reply/agent-runner-memory.ts, src/agents/pi-embedded-runner/compact.ts, src/agents/pi-embedded-runner/compact.queued.ts)
  • Vincent Koc: Recent history shows the queued embedded compaction wrapper was split in f1c4e2f, which is directly touched by this PR's queued budget clamping change. (role: adjacent area contributor; confidence: medium; commits: f1c4e2f11daf, 61da711b1a7e; files: src/agents/pi-embedded-runner/compact.queued.ts, src/plugins/provider-runtime-model.types.ts)
  • David Rudduck: History shows context-engine compact error and ownsCompaction hook behavior was added in the same compaction area, which is relevant to ok/compacted result semantics. (role: adjacent context-engine compaction contributor; confidence: medium; commits: f01c41b27a13; files: src/agents/pi-embedded-runner/compact.queued.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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 26, 2026
@clawsweeper

clawsweeper Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🌱 uncommon Pearl Crabkin

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🌱 uncommon.
Trait: watches the merge queue.
Image traits: location CI tidepool; accessory tiny test log scroll; palette coral, mint, and warm cream; mood focused; pose leaning over a miniature review desk; shell starlit enamel shell; lighting subtle sparkle highlights; background miniature CI buoys.
Share on X: post this hatch
Copy: My PR egg hatched a 🌱 uncommon Pearl Crabkin in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels May 26, 2026
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels May 26, 2026
@mcaxtr
mcaxtr force-pushed the fix/preflight-compaction-noop branch from 3b4e502 to 84400c9 Compare May 26, 2026 02:23
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels May 26, 2026
@mcaxtr
mcaxtr force-pushed the fix/preflight-compaction-noop branch from 84400c9 to 4230ce5 Compare May 26, 2026 02:53
@mcaxtr
mcaxtr merged commit bcde7b1 into main May 26, 2026
99 checks passed
@mcaxtr
mcaxtr deleted the fix/preflight-compaction-noop branch May 26, 2026 03:02
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 26, 2026
* fix(auto-reply): accept no-op preflight compaction

* fix(agents): clamp compaction runtime budget

* fix(agents): clamp queued compaction budget
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix(auto-reply): accept no-op preflight compaction

* fix(agents): clamp compaction runtime budget

* fix(agents): clamp queued compaction budget
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix(auto-reply): accept no-op preflight compaction

* fix(agents): clamp compaction runtime budget

* fix(agents): clamp queued compaction budget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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