How it works

Every LLM has a finite context window. As your conversation grows with file reads, tool outputs, and agent reasoning, it eventually approaches this limit. Context compaction solves this by intelligently compressing older parts of the conversation.

When enabled, Autohand monitors context usage and triggers compression at tiered thresholds:

ThresholdCompression levelWhat happens
70%LightRedundant tool outputs are removed (e.g., duplicate file reads)
80%MediumOlder conversation turns are summarized into concise notes
90%AggressiveOnly essential context is retained: current task, recent changes, key decisions

Enabling and disabling

Context compaction can be controlled via CLI flags, slash commands, or configuration:

CLI flags

# Enable context compaction
autohand --cc

# Disable context compaction
autohand --no-cc

Slash command

# Toggle during a session
/cc

# Status bar shows: [CC: ON] or [CC: OFF]

Configuration

{
  "ui": {
    "contextCompact": true
  }
}

Status display

When context compaction is enabled, the status bar shows:

[CC: ON] anthropic/claude-4-sonnet | 45,200 / 200,000 tokens

When a compaction event occurs, Autohand briefly displays a notification:

⚡ Context compacted: 180,000 → 95,000 tokens (47% reduction)

What is preserved

Compaction is designed to preserve the information that matters most:

  • Always kept: Current task description, recent file modifications, active plan steps, memory entries, system prompt
  • Summarized: Earlier conversation turns, completed tool sequences, resolved sub-tasks
  • Removed: Duplicate file reads, verbose command output, superseded search results

Tip: If the agent seems to forget context after compaction, use /memory to store critical facts as persistent memories that survive compaction.

When to use

  • Long coding sessions — Multi-hour sessions that would otherwise hit context limits
  • Large codebases — Reading many files consumes context quickly
  • Complex refactors — Tasks requiring many tool calls and iterations
  • Auto-mode — Extended autonomous sessions that run many iterations

You may want to keep it disabled when:

  • Working on short, focused tasks
  • Every detail of the conversation is critical
  • Debugging issues where earlier context matters

Frequently asked questions

What is context compaction in Autohand?

Context compaction automatically compresses conversation history when it approaches the model's context window limit. It triggers at tiered thresholds: 70% removes redundant tool outputs, 80% summarizes older turns, and 90% keeps only essential context. This lets you work in long sessions without losing important information.

How do I enable context compaction?

Run autohand --cc to enable context compaction from the command line. Inside a session, type /cc to toggle it on or off. The status bar shows [CC: ON] or [CC: OFF] to indicate the current state. Context compaction is also configurable in your settings file.