Skip to content

Feature: compaction.model — configurable model override for auto-compaction #19501

Description

@JoeProAI

Problem

Auto-compaction uses the session's current model (e.g., claude-opus-4-6). For large sessions, this means sending 200K+ chars to an expensive, slow cloud model to do what is essentially summarization of already-written text.

Compaction doesn't require frontier-level reasoning — it's condensing existing conversation. A cheaper/faster model (or a local one via Ollama) would produce adequate summaries at a fraction of the latency and cost.

Currently there's no way to override the model used for compaction without switching the entire session's model.

Proposed Solution

Add agents.defaults.compaction.model (same format as subagents.model or heartbeat.model):

{
  "agents": {
    "defaults": {
      "compaction": {
        "model": "ollama/qwen2.5:14b",  // or "xai/grok-4-1-fast-non-reasoning"
        "reserveTokensFloor": 20000
      }
    }
  }
}

When set, the compaction run would resolve this model instead of inheriting the session's model. When unset, behavior is unchanged (uses session model).

Why This Matters

  • Latency: Opus compaction on 350K chars takes 5-10 minutes via API. A local 14B model on an RTX 5080 could do it in under a minute.
  • Cost: For API-key users, compaction burns full-price input tokens on a task that doesn't need frontier intelligence.
  • GPU utilization: Users with capable local hardware (Ollama) can offload compaction to their GPU while keeping Opus for actual reasoning.
  • Precedent: subagents.model and heartbeat.model already exist for exactly this pattern — routing non-primary tasks to cheaper/faster models.

Implementation Notes

The compaction model is resolved in src/agents/pi-embedded-runner.ts where createAgentSession receives the model. The change would:

  1. Read compaction.model from config (same resolver as subagents.model)
  2. Before the compaction createAgentSession call, swap to the compaction model if configured
  3. Fall back to session model if compaction model is unavailable

Environment

  • OpenClaw v2026.2.15
  • Primary model: claude-opus-4-6
  • Hardware: RTX 5080 16GB, Ollama available locally
  • Observed compaction time: 5-10 minutes on 350K char sessions via Anthropic API

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions