Arcana ARCANA

Session Compaction

Long sessions consume more tokens and cost more. Arcana's compaction system automatically summarizes older parts of the conversation when you approach the context limit, keeping sessions going without hitting a wall.

How It Works

When token usage reaches the compaction threshold (default 85% of the model's context window), Arcana:

  1. Identifies the oldest messages in the session
  2. Summarizes them using the utility model
  3. Replaces the original messages with the summary
  4. Preserves key facts and context in the summary

The agent retains awareness of what was discussed, just in compressed form.

Auto-Compaction

By default, compaction is automatic. It triggers when usage exceeds the threshold:

# Default: triggers at 85% of context window
arcana
# ... long session ...
# "Session compacted: 45,000 tokens → 12,000 tokens"

Manual Compaction

# In the TUI, type:
/compact

# Or from CLI:
arcana run --compact "continue where we left off"

Configuration

Compaction settings in ~/.arcana/config.json:

{
  "compaction": {
    "auto": true,
    "threshold_percent": 85,
    "intra": true,
    "intra_min_steps": 3,
    "intra_min_tokens": 5000
  }
}

Config Reference

KeyTypeDefaultDescription
compaction.autobooleantrueEnable automatic compaction
compaction.threshold_percentnumber85Trigger when usage reaches this % of context (1–100)
compaction.intrabooleantrueMid-loop compact during multi-step tool runs
compaction.intra_min_stepsnumber3Min agent loop steps before intra compact
compaction.intra_min_tokensnumber5000Min usage before intra compact is worth it

Intra-Loop Compaction

During complex multi-step tool runs (e.g., refactoring multiple files), the agent loop can consume many tokens. Intra-loop compaction summarizes intermediate steps mid-execution.

# Example: agent runs 10 tool calls in a loop
# After step 3, if tokens > 5000 and steps >= 3:
# "Compacting intermediate steps..."
# Agent continues with summarized context

Set "intra": false to only compact between user turns.

Disabling Compaction

{
  "compaction": {
    "auto": false
  }
}

Manual /compact still works when auto is disabled.

When Compaction Happens

TriggerWhenCan disable?
Auto (between turns)Usage > threshold at end of turnYes (auto: false)
Intra-loopMid-execution during tool loopsYes (intra: false)
ManualUser types /compactNo

Tips

  • Lower the threshold (e.g., 70%) if you want more aggressive cost savings
  • Higher thresholds (e.g., 90%) preserve more context but cost more
  • Use a cheap utility model for compaction summaries to save costs
  • Compaction preserves key facts — the agent remembers what was discussed
  • Long sessions with many tool calls benefit most from intra-loop compaction
Last updated: Jul 24, 2026