---
title: "compact-1: long agent sessions, short history"
description: "compact-1 fits an agent's whole conversation inside the token budget you set."
canonical: https://caveman.so/models/compact-1
last-updated: 2026-10-18
---

# compact-1: long agent sessions, short history

compact-1 fits an agent's whole conversation inside the token budget you set.
It pins every user message and constraint, keeps the latest turns word for
word, and keeps the lines of old tool output the next step is likely to need.
There is no summary model call, and what it keeps is the original text. This
is compaction of a whole history; compression of one payload is
[trim-1](https://caveman.so/models/trim-1).

- 3.8 ms p50 per compaction; 45 to 52 ms p95 on 200k-token histories, one
  CPU core. LLM summaries in the same benchmark took 5.7 to 17 s.
- From older tool output it keeps the lines the next step is likely to use.
- It never compacts a compaction: the start of the history stays byte for
  byte the same, so the provider's prompt cache keeps hitting.
- Dropped spans are stored and come back by handle (`zdr` stores nothing).
- On Caveman Cloud only.

## Measured

One build, 2026-10-13/14. Holdout splits run once; token counts are local
`cl100k_base`, labelled inferred. The comparison arms reimplement each tool's
compaction method and summarise with gpt-6-luna at low effort; they are not
the shipped tools.

Evidence the agent went on to use, kept at 15% of the history (600 holdout
cases, weighted recall): compact-1 64.2, pi's method 45.0, Factory's method
42.5, OpenHands summary 39.2, OpenCode's method 28.9, Codex's method 26.6.

Asked questions about the run so far, a model answered from compact-1's
history 99% as well as from the full history (68.0% against 68.7%).

Long-Horizon-Terminal-Bench 1.0, 28 tasks, one seed, gpt-6-luna agent,
compacting at 32k: no compaction $0.103 per task (reward 0.379), compact-1
$0.078 (0.374), pi's method $0.080 (0.380). Every compactor matched no
compaction at about a quarter less per task; none separated from another.
With gpt-6.1-sol, which compacts about once a run, the saving was about 5%.

Real compactions in our own sessions are followed by a re-read within ten
turns 28% of the time in Claude Code and 33% in Codex (aggregates only).

## API

```sh
curl https://gateway.caveman.so/v1/compact \
  -H "Authorization: Bearer $CAVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "..."}], "budget_tokens": 48000}'
```

Body `{messages, budget_tokens}`, OpenAI or Anthropic message shape. The
budget is counted after the leading system messages. Returns `{messages,
tokens_before, tokens_after, recovery_handles?, model}` in your shape; a
history that already fits comes back as sent. Up to 8 MB a call.

10M tokens free each month per organisation, on every plan, then $0.10 per
1M tokens in (about $0.02 for a 200K-token compaction). Free during the
preview; billing starts in 2027 at the earliest.

One 200K-token compaction at October 2026 list prices, with a summary of
about 4K tokens: an Opus 5.5 summary $0.88 with a cold cache or $0.12 warm,
a Sonnet 5.5 summary $0.06 warm, Morph Compact about $0.09, compact-1 $0.02.

Get an API key: https://app.caveman.so/signup
