Context compaction
Long sessions never hit the wall. Empryo folds older work into a compact summary in about a second and keeps every file and decision.
Copy & share
On this page7 sections
Every model can only read so much at once. When a long session gets close to that limit, Empryo compacts it: older turns fold into a compact summary of the work, your most recent turns stay word for word, and you keep going in the same session. No restart, no lost thread.
It kicks in automatically when the context reaches 95% of the model's window, and you can run it yourself at any time:
/compactWhy it feels instantLink to this section
- Up to 76× smaller. A million characters of session history fits in a summary the size of a short file, bringing a full context window back down to single digits.
- About a second. Most compactions finish before you notice, with zero extra model calls and nothing extra on your bill.
- Nothing important left behind. Every file the agent edited or read, the commands it ran and how they turned out, the decisions it made and why, the errors it hit and how it fixed them.
- No re-exploring. The agent picks up exactly where it left off instead of re-reading files or re-running tests it already ran.
- It never gets stuck. If a model is slow, busy or out of quota, compaction still completes.
Tested on real coding sessions with Claude Opus, Sonnet and Haiku and with GPT models, with reasoning on and off.
Nothing said is lostLink to this section
The summary keeps the shape of the work, not every word: a long message is cut to its first few hundred characters, and a line that ends in … is one of those cuts. Everything it leaves out stays in the session's record on disk, and the agent reads it back word for word with the history tool: your exact messages, its own earlier answers, the full output of every tool call, and the summaries earlier compactions left.
history with scope: "project" also searches this project's earlier sessions, newest first, so the agent can look up how something was settled last week. A one-off headless run without --save-session keeps no record, so there is nothing to search.
Repeated output is sent onceLink to this section
When the agent reads a file it already has, or runs the same grep, shell, git or project call again and gets the same output, the model gets a short note pointing to the earlier copy instead of the full text again. The note is used only when both are true:
- The new output is byte for byte the same as the last one. The call always runs, and a file is hashed when it is read, so an edit from another tab, your editor or git always comes through in full.
- The earlier copy reached the model intact and is still in the request. Once compaction, pruning or context cleanup removes it, the next identical call sends the full output again, and a note already sent for it is replaced by the content or by a request to read again.
Your transcript always keeps the full output. To force the full text anyway, the agent passes fresh: true.
SettingsLink to this section
{
"compaction": {
"triggerThreshold": 0.95,
"keepRecent": 4
}
}| Key | Default | What it does |
|---|---|---|
strategy | "auto" | Set to "disabled" to turn off automatic compaction |
triggerThreshold | 0.95 | Compact automatically at this share of the context window |
keepRecent | 4 | How many recent messages stay word for word. When the newest turn alone is bigger than that budget, its earlier steps go into the summary and only its newest steps stay |
llmExtraction | true | Let a model add a short written recap when it helps |
Toggle automatic compaction with /compact settings. /compact logs shows past compactions.
After a breakLink to this section
When you come back to a tab after a while, the provider's prompt cache has expired, so the next request pays to cache the whole history again. With compaction.onResume on, Empryo compacts first instead: the first turn after the break starts from the summary and your most recent turns, and every later request in that tab reads a much smaller history.
{
"compaction": {
"onResume": true,
"resumeAfterMinutes": 60,
"resumeMinTokens": 150000
}
}It only runs when all of these hold:
- You sent the message yourself. Goal loops, reviews, background wake-ups and recovered turns never compact on resume.
- You were away at least
resumeAfterMinutesand at least as long as the prompt cache lives (5 minutes or 1 hour, depending oncache.ttl). - The context the last request sent was at least
resumeMinTokenstokens. - The session is saved and the
historytool is on, so anything the summary leaves out can still be read back word for word.
A note in the conversation says how long you were away and how big the context was. If compaction fails, the turn is sent as it is.
Which model helpsLink to this section
Most compactions need no model at all. When a short written recap helps, Empryo uses the model in the compact slot of the task router, so point it at something fast and inexpensive:
{
"taskRouter": {
"compact": "google/gemini-2.5-flash"
}
}A recap is a summary, not a reasoning task, so it runs at the model's lowest reasoning level, not your tab's. To change that, set an effort on the compact lane in the router.
What you'll seeLink to this section
- A spinner while compaction runs.
- A message showing how full the context was before compaction, as your provider counted it. When a tool result would have pushed the next request past the window, it also names the size of that request, which is never sent. When the newest turn was longer than the kept budget it also says how many of its earlier steps went into the summary.
- After the next request, a second message with the new size as your provider reports it. Until then the context gauge shows no number.
- If the measured size is still at the compaction trigger, so the next compaction would come right away, a note says so. A result between the target and the trigger is normal when the newest turn is large: it is kept whole, and nothing is reported.