# What's in the conversation, and how does Irene keep it from growing forever?

**Every step, the model is sent the agent's instructions, its tool descriptions, and the conversation so far. Irene keeps the start of that stable so it stays cached and cheap, stamps fresh details like the time onto your message instead, and when the conversation nears the model's limit, folds older turns into a structured summary that keeps every fact, file and handle. That happens in the background after your turn.**

---

## What makes it different

| what it does | the primitive behind it | what that buys you |
|---|---|---|
| **A stable, cached start** | The instructions and tool descriptions never change mid-chat; the date and time ride on your message, not the instructions | Prompt caching keeps re-sending the start cheap, often at a tenth of the price |
| **Compaction that keeps what matters** | A structured summary with fixed headings: your asks, decisions, facts, files, links, open threads, and **every stored-result handle, copied exactly** | Old data stays reachable after a fold; nothing important is paraphrased away |
| **Compacts in the background** | The fold starts after a turn ends; the next turn waits only if it isn't finished | You rarely wait for it |
| **You set the fold point** | `/autocompact` per chat or per agent, as a percent of the model or a token count, capped at 90% | The fold happens where your work, and your bill, say it should |
| **Summaries build on summaries** | Each fold is given the previous summary, so repeated folds don't lose earlier facts | Long chats stay coherent |
| **Starts each chat knowing you** | A short picture of who you are and what's in flight is added to the first turn | You don't re-explain yourself |

---

## How it works

### What the model receives each step

1. **The agent's instructions**, plus how to read stored results. These stay the same all chat.
2. **Tool descriptions** for every tool the agent holds. This is why rarely used toolkits aren't loaded. → [Toolkits overview](https://mycelen.com/manual/reference/toolkits/overview)
3. **The conversation** (or its summary plus recent turns).
4. **Your message, with additions** in this order: expanded commands and skills, the current date and time, voice and overlay notes, your language, the design project, attached files and tagged elements, expanded `#vault`/`#memory`/`#plan`/`#summary`/`#project` references, any pending offer, and, on a chat's first turn, a snapshot of who you are, your goals and what's in flight.

**Why the time goes on your message:** if the date were in the instructions, the start would change every minute and couldn't be cached. On your message it's both fresher and cheaper.

### Prompt caching

Models that support it reuse the unchanged start of each request at a fraction of the price: about a tenth for cached reads on most providers. Irene marks the cache points itself where a provider needs that. Nothing earlier in the conversation is ever rewritten, so the cache holds. Your cache hit rate is shown in **Observability**.

### Compaction

- **When:** after a turn, if the largest single request in it reached **80% of the model's context window**. For models on your own computer, that's the window your local server actually serves.
- **How:**
  1. One call on a small background model writes a summary under fixed headings: **user asks · decisions · facts · file references · URLs · open threads · handles**. Empty headings are skipped.
  2. It's told to keep exact ids, paths and numbers, and not to invent anything.
  3. The previous summary is fed in, so nothing from earlier folds is lost.
  4. **Every stored-result handle is copied in exactly**, so data summarised away can still be searched.
- **Background:** the fold runs between turns. If you send a message before it's done, that turn waits ("Compacting…").
- **Safety:** after 3 failures in a row, automatic compaction turns off for that chat.

### Your own fold point

The 80% above is the default. `/autocompact` replaces it for one chat, or for every chat with
one agent — **a percent** of the model's memory (`60%`) or **a number of tokens** (`200k`,
`1m`, `200,000`).

- **The value is kept as you typed it.** `60%` stays a percent, so switching to a bigger model
  moves the fold point with it; a number stays that number.
- **Which one wins:** this chat's own setting → this agent's → the agent's built-in pin → the
  80% default.
- **The ceiling is 90%**, whatever you typed. Compaction runs *after* the turn that crossed
  the line, so that turn still has to fit; a limit at 100% would leave it nowhere to go. The
  note after you set it says so, and says that your number applies on a bigger model.
- **The floor is 10% or 20,000 tokens.** Every fold is a model call; folding every other turn
  is not a setting, it is a tax.
- **It cannot be turned off.** A full memory stops the chat. The highest you can set is 90%.
- **The note always gives both numbers** — the token count and the percent of the model's
  memory — and says when a model charges more per token past a certain size. `/context` then
  reports the same fold point, because both read the one setting.
- **It applies from the next turn**, and survives closing the app (the chat's setting on the
  chat, the agent's on disk with the agent's settings).
- **In a team chat it follows the @ picker**, because a team folds one agent at a time: no
  target sets the lead's, `@Quant` sets Quant's, `@all` sets every agent's. Setting it for a
  member keeps that member's history folding on its own, without touching the lead's.
- **Kept verbatim:** the main agent folds everything into the summary. The Coding agent always keeps its latest turn word for word, so the most recent code diff is never blurred.

### Commands

| command | does |
|---|---|
| `/context` | shows what the chat is holding, including whether it's been folded before |
| `/compact` | folds now ("Nothing to compact yet" if there's nothing to fold) |
| `/autocompact` | shows when this chat folds: this chat's setting, this agent's, and the default |
| `/autocompact 60%` | this chat folds at 60% of the model's memory |
| `/autocompact 200k` | this chat folds at 200,000 tokens |
| `/autocompact 50% agent` | every chat with this agent folds at 50%, unless a chat has its own |

---

## Where you see it

- A quiet note in the chat: **Compacted context — folded N older turn(s) into a synopsis.** It stays after a restart.
- **Compacting…** while a fold you're waiting on finishes.
- The full chat history in the app is never shortened. Only what the model is sent is.

---

## What it costs

- **Compaction:** one call on a small background model, billed like any other usage.
- **Caching** lowers the price of every step. Your hit rate is in **Observability**.

---

## Limits

- A summary is still a summary. Exact long passages from early turns live in stored results or the vault, not in the fold.
- After 3 failed folds in a row, automatic compaction stops for that chat. `/compact` still works.
- The snapshot of who you are is added on a chat's first turn, and again after a fold.

---

## Related

- [Offload](https://mycelen.com/manual/reference/learning/offload): big results never enter the conversation
- [Toolkits overview](https://mycelen.com/manual/reference/toolkits/overview): why tool descriptions are kept few
- [Chronicle](https://mycelen.com/manual/reference/toolkits/chronicle): the memory and vault behind the snapshot and `#` references
- [Main agent](https://mycelen.com/manual/reference/agents/main) · [Coding](https://mycelen.com/manual/reference/agents/coding)

[Ask Irene about this]
