Repository navigation
fix(agents): cap effective compaction reserve - #100621
Merged
Merged
Conversation
Co-authored-by: Vincent Koc <[email protected]>
Contributor
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(agents): cap effective compaction reserve This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Contributor
Author
|
Land-ready review completed at exact head What was reviewed:
Proof:
Known proof gap: no live Ollama generation. The changed contract is directly exercised at the real settings-manager and compaction-predicate boundary. |
Contributor
Author
|
Merged via squash.
|
This was referenced Jul 6, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 6, 2026
* fix(agents): cap effective compaction reserve Co-authored-by: Vincent Koc <[email protected]> * docs(changelog): link small-context compaction fix --------- Co-authored-by: Vincent Koc <[email protected]>
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 Problem This Solves
For a known 16K model context, OpenClaw capped
reserveTokensFloorbut then restored the uncapped 16,384-token runtime default through the finalMath.max. The shared compaction predicate therefore returned true from the first token.This supersedes #87927 with the proven narrow fix. The original recent-tail cap was not replayed: agent-core treats
keepRecentTokensas a cut-point target rather than a hard upper bound, so claiming it prevented every post-compaction overflow would be incorrect.Why This Change Was Made
The final effective reserve now uses the same known-context maximum already applied to the floor and preemptive compaction. Explicit reserves are capped too, while floor-disabled low reserves, unknown contexts, and large contexts preserve their existing behavior.
User Impact
Small-context local models no longer enter compaction from token one because the runtime default or an oversized configured reserve consumed the whole context window. Existing
keepRecentTokenssemantics remain unchanged.Evidence
SettingsManager,applyAgentCompactionSettingsFromConfig, and agent-coreshouldCompact: beforereserveTokens=16384,shouldCompact(1)=true; afterreserveTokens=8384,shouldCompact(1)=false.pnpm test src/agents/agent-settings.test.ts --reporter=dot— 31 tests passed on Blacksmith Testbox.Co-authored with and changelog credit preserved for @vincentkoc.