-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Context pruning mode 'off' not preventing compactions (Anthropic API key, cache-ttl smart defaults) #48579
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.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.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.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: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.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.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.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: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Priority
None yet
Summary
Context pruning set to
mode: "off"withttl: "999h"andkeepLastAssistants: 999, but compactions continue to fire aggressively (~82 compactions in a single day) at only 12-16% context usage (120-160k of 1M tokens).Environment
anthropic/claude-opus-4-6(1M context window)anthropic:default,anthropic:second,anthropic:bhide)Config
{ "agents": { "defaults": { "contextTokens": 1000000, "contextPruning": { "mode": "off", "ttl": "999h", "keepLastAssistants": 999 }, "compaction": { "mode": "default", "reserveTokensFloor": 200000 } } } }Expected Behavior
With
contextPruning.mode: "off"andreserveTokensFloor: 200000, compaction should only trigger when context usage exceeds ~800k tokens (1M - 200k reserve).Actual Behavior
Compactions fire constantly — even at 12-16% context usage (120-160k tokens). The Post-Compaction Audit fires on nearly every message, indicating context is being reset.
Investigation
Smart defaults code path (
applyContextPruningDefaults)The code in
daemon-cli.jschecks:Since
mode: "off"is explicitly set, this guard should prevent the smart defaults from overriding. Verified in bothconfig-BseT0AMx.jsanddaemon-cli.js.Config file verification
The config file on disk is correct —
contextPruning.modeis"off", confirmed viagrepand JSON parsing. No per-agent overrides exist.Session file evidence
Multiple session JSONL files are created per hour, suggesting new sessions are being spawned rather than continuing existing ones. Auth tokens alternate between
anthropic:defaultandanthropic:secondwithin a single session file.Config-audit.log
Shows config being rewritten periodically (~85 writes total), each potentially triggering a daemon restart via SIGUSR1, which resets the session context.
Hypotheses
Anthropic prompt cache TTL expiry — When the server-side prompt cache (5-min TTL) expires between messages, the uncached token cost may trigger compaction logic even when total context is well under the threshold.
Auth profile rotation — Requests route through different Anthropic auth profiles (
defaultvssecond). If cache-ttl pruning is applied per-profile or cache state isn't shared across profiles, each profile switch may effectively reset the cache window.Config rewrites triggering restarts — The config-audit log shows periodic config writes that cause daemon restarts, which reset session context regardless of pruning settings.
Compaction mode
defaultmay have additional triggers beyond justreserveTokensFloorthat aren't documented.Reproduction
anthropic/claude-opus-4-6with API key auth (multiple profiles)contextPruning.mode: "off",contextTokens: 1000000,reserveTokensFloor: 200000Impact
Requested
mode: "default"beyondreserveTokensFloor