-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Add absolute-token trigger for compaction (independent of model context window) #81856
Copy link
Copy link
Open
Labels
P3Low-priority cleanup, docs, polish, ergonomics, or speculative work.Low-priority cleanup, docs, polish, ergonomics, or speculative work.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Metadata
Metadata
Assignees
Labels
P3Low-priority cleanup, docs, polish, ergonomics, or speculative work.Low-priority cleanup, docs, polish, ergonomics, or speculative work.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Priority
None yet
GitHub Issue Draft
Repo: openclaw/openclaw
Title: Add absolute-token trigger for compaction (independent of model context window)
Submit with:
Body
Problem
agents.defaults.compaction.memoryFlush.softThresholdTokensis described as the trigger threshold for pre-compaction memory flush, but it's actually distance to the model's context limit, not an absolute usage count.This means:
softThresholdTokens: 50000fires at ~150k tokens used. On a 1M-context model, it fires at ~950k tokens used. On a 32k model, it fires almost immediately.window - Nper model and update it whenever they change models."Compaction Memory Flush Soft Threshold") strongly imply absolute behavior, leading to incorrect mental models. (Confirmed firsthand: I configuredsoftThresholdTokens: 50000expecting compaction at 50k used, then sat at 190k tokens with no compaction firing.)Proposed solution
Add a sibling field:
Semantics:
forceFlushTranscriptBytes).absoluteThresholdTokensis model-independent and survives model switches.undefined), preserving current behavior.Why this matters
agents.defaults, a per-model relative threshold is wrong for at least one of them.Alternatives considered
maxHistoryShare: caps post-compaction retention, doesn't control trigger timing.Affected paths
agents.defaults.compaction.memoryFlushsoftThresholdTokensis currently evaluated)Willing to PR?
I'm a user, not a contributor (yet) — happy to test or iterate on the spec if a maintainer scopes the change. If the team prefers to keep
softThresholdTokensand just addabsoluteThresholdTokensalongside, that's the smallest viable change.Environment
2026.4.29 (a448042)anthropic/claude-opus-4-7