Repository navigation
fix(compaction): plan cut points in trigger units - #115309
Conversation
|
Merged via squash.
|
…224005-host * origin/main: (72 commits) fix: macOS-only Parallels smoke harness regression (#75293) fix(ios): use configured speech language for system voice (#113372) refactor: centralize isolated agent test ownership (#115340) test(ui): stabilize browser route readiness (#115320) fix(cron): clear automation after failed scheduler shutdown (#115316) fix: keep isolated gateway workspaces and skills inside state dir (#114487) docs: document local TTS on macOS, Linux, and Windows (#110230) fix(tasks): clone only the requested task page (#114277) fix(agents): prevent Code Mode resume loss and unbounded preparation (#115314) fix(process): preserve the first process cancellation reason (#115317) fix(nostr): report unavailable ingress when queue open fails (#115313) fix: prevent Slack and Feishu ingress startup leaks (#115295) fix(slack): avoid unsafe emphasis boundaries (#111575) fix: prevent changed checks from expanding into full lint (#115322) fix(codex): stabilize prompts and expose real cache regressions (#115238) refactor(ui): derive page route specs from the route table (#115214) fix(compaction): plan cut points in trigger units (#111886) (#115309) fix: prevent cron and gateway stress-run timeouts (#115241) fix(ci): validate frozen Matrix QA targets (#115298) test(macos): block real process fallthrough (#113337) ... # Conflicts: # CHANGELOG.md
…afea23-host * origin/main: (72 commits) fix: macOS-only Parallels smoke harness regression (openclaw#75293) fix(ios): use configured speech language for system voice (openclaw#113372) refactor: centralize isolated agent test ownership (openclaw#115340) test(ui): stabilize browser route readiness (openclaw#115320) fix(cron): clear automation after failed scheduler shutdown (openclaw#115316) fix: keep isolated gateway workspaces and skills inside state dir (openclaw#114487) docs: document local TTS on macOS, Linux, and Windows (openclaw#110230) fix(tasks): clone only the requested task page (openclaw#114277) fix(agents): prevent Code Mode resume loss and unbounded preparation (openclaw#115314) fix(process): preserve the first process cancellation reason (openclaw#115317) fix(nostr): report unavailable ingress when queue open fails (openclaw#115313) fix: prevent Slack and Feishu ingress startup leaks (openclaw#115295) fix(slack): avoid unsafe emphasis boundaries (openclaw#111575) fix: prevent changed checks from expanding into full lint (openclaw#115322) fix(codex): stabilize prompts and expose real cache regressions (openclaw#115238) refactor(ui): derive page route specs from the route table (openclaw#115214) fix(compaction): plan cut points in trigger units (openclaw#111886) (openclaw#115309) fix: prevent cron and gateway stress-run timeouts (openclaw#115241) fix(ci): validate frozen Matrix QA targets (openclaw#115298) test(macos): block real process fallthrough (openclaw#113337) ... # Conflicts: # CHANGELOG.md
Independent reproduction and verificationTL;DR: Reproduced on npm stable Root cause (short)
Reproduction (full)Environment:
Command: Observed on A local forwarding proxy captured the summarizer request before it left OpenClaw: The OpenClaw then wrote a compaction entry whose structured summary sections were all Bundle analysis (matched the capture)Why this happens (confirmed in the
Note: because the budget is compared against the character heuristic rather than provider tokens, the trigger condition is not "session under 20k provider tokens" — sessions well above 20k provider-reported tokens can be affected too. Also verified on the old build: Verification after the upstream fixWe repeated the same isolated test after upgrading to: Bundle-level (read-only, same transcript, pre-compaction state): The beta.7 bundle contains the changes from this PR (trigger-unit scaling of End-to-end with the real provider (SiliconFlow,
This independently confirms that the compaction-planner/manual-compaction changes represented by this PR fix the reproduced empty-summary path. NoteThe live end-to-end run used the auto-migrated Suggestion: please ship this in a stable release soonFor context (dates verified against npm / GitHub): The No credentials, authorization headers, private paths, complete transcripts, or auth databases are included. |
What Problem This Solves
Auto-compaction's trigger measures provider context tokens (usage-based, including system prompt and tool schemas), but the cut-point planner accumulates a chars/4 estimate that excludes them. When provider usage is high while the transcript's estimated size is small (cached system prompt + tool definitions dominating), the cut walk never reaches the
keepRecentTokensbudget,cutIndexstays at the first entry, and compaction selects zero or near-zero messages — freeing nothing while the trigger keeps firing. Downstream this exhausts the overflow-recovery ladder (residual reports in #78562's thread) and was the root of the "safeguard thrash" residual from #100982.Closes #111886.
Why This Change Was Made
prepareCompaction(packages/agent-core/src/harness/compaction/compaction.ts) now normalizes the retained-tail budget into trigger units: it computes the ratio of provider usage tokens to the summed per-message estimates and divideskeepRecentTokensby it (clamped to ≥1 so estimates above usage never inflate the tail, and bounded so the budget never drops below one token). The kept tail then costs ~keepRecentTokensin the same units the trigger measures, so the cut point advances past compactable prefix whenever the trigger fires. When no finite usage/estimate ratio exists, the scale is 1 and behavior is byte-identical to before. Auto-skip on genuinely empty cuts and the manualkeepRecentTokens: 0full-branch retry are preserved unchanged.User Impact
Sessions with high provider usage but compact transcripts (the common cached-system-prompt shape) now free real tokens on auto-compaction instead of entering repeated no-progress compaction cycles.
Evidence
node scripts/run-vitest.mjs packages/agent-core/src/harness/compaction/compaction.test.ts— 22 tests passed, including the new regression translated from the issue: ~170k provider usage over a short transcript must select a non-empty old prefix.