Closed
Conversation
Persist prompt-cache telemetry after turns and use it to gate incremental leaf compaction. Hot cache sessions now defer best-effort incremental passes unless raw history pressure is clearly above target, while cold cache sessions can run bounded catch-up passes in a single maintenance cycle. Full threshold sweeps keep their existing behavior. Also add cacheAwareCompaction config/schema support, docs, a changeset, and regression coverage for hot/cold/unknown prompt-cache behavior. Regeneration-Prompt: | Implement the cache-aware incremental compaction spec for lossless-claw using the new prompt-cache telemetry exposed by the dependent OpenClaw branch tied to openclaw/openclaw#62179. Persist lightweight per- conversation cache telemetry after each turn, classify sessions as hot, cold, or unknown, and use that state to decide whether afterTurn() should run incremental leaf compaction. Preserve the existing full-sweep compaction behavior, but let cold-cache sessions do a bounded number of extra leaf passes to catch up while hot-cache sessions defer passes unless raw history pressure is clearly above target. Add the minimal config surface for enabling the feature and setting the cold-cache pass cap, keep the plugin manifest and docs in sync, and cover the behavior with focused engine and config tests.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This PR implements cache-aware incremental compaction for lossless-claw using OpenClaw prompt-cache telemetry. It persists per-conversation cache observations after each turn, defers best-effort incremental leaf compaction while the prompt cache is hot, and allows bounded catch-up passes once the cache goes cold. This depends on openclaw/openclaw#62179, which provides the runtime prompt-cache signals.
Why
The spec here is to avoid churning the prompt-cache prefix when the session is actively benefiting from cache reuse, while still letting lossless-claw catch up once that benefit is gone. The existing token-driven incremental behavior had no visibility into real cache state, so it could compact at the wrong time.
Changes
Testing
npx vitest run test/config.test.ts test/engine.test.ts test/session-operation-queues.test.ts test/expansion.test.ts test/circuit-breaker.test.ts --exclude='.worktrees/**' --exclude='**/.worktrees/**'