-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Feature]: Compaction: configurable model override + flush-then-reset mode #30452
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.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:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.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.enhancementNew feature or requestNew feature or requestimpact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.Auth, provider routing, model choice, or SecretRef resolution may break.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.Security boundary, credential, authz, sandbox, or sensitive-data risk.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.
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.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:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.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.enhancementNew feature or requestNew feature or requestimpact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.Auth, provider routing, model choice, or SecretRef resolution may break.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.Security boundary, credential, authz, sandbox, or sensitive-data risk.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.
Type
Fields
Priority
None yet
Summary
Compaction: configurable model override + flush-then-reset mode
Problem to solve
Problem
Compaction and memory flush both use the session model with no override. For Opus sessions ($5/$25 per MTok), housekeeping costs dominate:
reasoning: "high"thinking tokens billed at output rate)For sessions that compact 3-5x/day, that's $3-20/day in pure housekeeping on a single Opus agent.
Proposed solution
Proposed Solutions
1.
compaction.model- Override the summarization modelAllow specifying a cheaper model for compaction summarization calls:
{ "agents": { "defaults": { "compaction": { "model": "anthropic/claude-sonnet-4-6" // or haiku } } } }Summarization is not a hard reasoning task. Sonnet ($3/$15) or Haiku ($1/$5) can produce structured checkpoint summaries at 60-95% cost reduction. The
reasoning: "high"flag on compaction calls could also be made configurable or removed entirely for summarization.Estimated savings: Sonnet compaction ~$0.15-0.30/cycle vs Opus ~$0.90-1.13/cycle.
2.
memoryFlush.model- Override the flush modelSame pattern for the pre-compaction memory flush turn:
{ "agents": { "defaults": { "compaction": { "memoryFlush": { "model": "anthropic/claude-sonnet-4-6" } } } } }Flush is a simple "write memories to disk" task - doesn't need the most capable model.
3.
memoryFlush.resetAfterFlush- Flush then reset instead of flush then compactThis is the highest-impact change. Currently the flow is: flush → compact. But if flush writes everything important to disk, compaction is redundant. The agent can just reset and boot fresh from its workspace files.
{ "agents": { "defaults": { "compaction": { "memoryFlush": { "enabled": true, "resetAfterFlush": true // hard reset after flush, skip compaction entirely } } } } }Flow: context hits threshold → flush writes durable memories to disk → session resets → agent boots fresh with full context headroom, reads workspace files to pick up context.
Alternatives considered
No way for agent to change models or self-reset after memory flush...
Impact
Why this works:
Cost comparison per cycle (Opus):
Combined with model override, flush-then-reset on Haiku would be 15-50x cheaper than the current safeguard compaction flow.
Evidence/examples
No response
Additional information
Context
generateSummary()inpi-coding-agent/dist/core/compaction/compaction.jspasses the session model directlypi-embeddedalso usesctx.model ?? runtime?.modelwith no override pathreasoning: "high"(extended thinking), generating expensive thinking tokens billed at output rate ($25/MTok for Opus)runMemoryFlushIfNeeded()which usesrunWithModelFallback()inheriting the session model/resetis a user-facing command only/resetviaopenclaw message sendfrom the bot itself is rejected (not authorized sender)Environment