# Context & cost

_What Monix Agent keeps in the conversation, what it drops, and the settings that decide it: CAST, GPC, compaction, preload._

A long mission reads far more than fits in one context window.
What Monix Agent keeps, what it drops, and when it does the work of shortening — that
is the difference between a mission that finishes and one that runs out of room
halfway through. These are the parts that manage it, and the choice each one
leaves you.

## Why this exists at all

Every call sends the whole conversation again. Providers charge far less for
the part they have already seen — the *cached prefix* — than for fresh
text. Two consequences run through everything below:

So "the context is getting long, drop something" is the wrong instinct. The
question is whether dropping pays for itself before the mission ends.

## Trimming old tool output

Old tool results are replaced with a short placeholder — the file is named,
the content is gone. Settings ▸ Advanced ▸ **Trim old tool output at**
sets the threshold as a percentage of the compaction threshold (0–95, default
80). Once the conversation passes it, Monix Agent shortens the oldest and
already stale results down to a target of at most a quarter of the context
budget and half the threshold.

Shortening rewrites the history and invalidates the cached prefix from that
point on. It therefore waits while the cache is warm: it runs only when the
cache has run out — you paused for longer than the cache TTL below — or the
conversation has reached the compaction zone anyway. There is no price
arithmetic and no choice of how eager it should be.

### What it never does

### The setting

**Trim old tool output at** is a percentage of the compaction
threshold, 0 to 95 in steps of 5, 80 by default. Once the conversation passes
it, older tool results are shortened; at 0 this trim is off and only compaction
shortens the conversation. Content that has become wrong is still removed at
any setting. The four older presets are gone in this release.

## GPC — pre-compression

When you continue a session, everything said before it comes along. GPC
shortens that carried conversation *before* the new mission starts,
rather than in the middle of it. The difference matters: shortening mid-mission
throws away the cached prefix exactly when the agent is busy, while doing it at
the start costs nothing that was not going to be paid anyway.

| Setting | Behaviour |
|---|---|---|
| **on** | Every mission starts from a shortened
 history. |
| **off** | The default. The conversation is carried
 as it is. |
| **smart** | Decided per mission: a small model
 looks at your latest messages and judges whether the new task depends on
 the detail of the old ones. |

Set it under Settings ▸ Advanced ▸ **GPC pre-compression**.
Shortening rewrites the history, and what was condensed is not read again,
which is why it is off unless you choose it. The models that do the work are
the roles *gpc* and *gpc_gate* under Settings ▸ Models; point them
at something cheap — otherwise you pay for the history once more just to make it
shorter.

What survives is the substance: decisions, constraints, what was tried and
what it did. What goes is the volume — long outputs, repetition, the road not
taken.

## Compaction

When a session reaches 75 % of its context budget, Monix Agent writes a summary of
the conversation so far and continues from it; the newest part of the
conversation stays word for word. The summary keeps the thread of
the work — the goal, the decisions, the state of the files — and you can read
it. It is written by the *compactor* role, which you can give its own
model under Settings ▸ Models.

`/compact` does it now, without waiting for the limit. While a
mission is running it says so and leaves the mission alone: it compacts by
itself if the conversation grows too big.

| Setting | Where | What it does |
|---|---|---|---|
| Compaction ask | General; per project under Project | *off*
 compacts silently, *always* asks first, *smart* (the default)
 asks only when the compactor itself is unsure. A project can override the
 global choice. |
| Compaction max cut | Advanced | How much of the conversation one
 compaction may remove in a single step: 10 to 100 %, default 50 %. |
| Compaction cooldown | Advanced | Rounds that must pass after
 a compaction before the next one may start. Default 3. |

`/context` shows where the tokens are going before you decide. It
splits them in two groups: what is paid once because it sits in the cached
prefix (system rules, paths and scopes, mode and rules, the skill index, tool
schemas, the conversation), and what is paid again with every message (file
changes, session memory, preloaded files, the memory bundle, your message).

## Context budget

How much of the model's window Monix Agent is willing to fill before it starts
managing it. Settings ▸ Advanced ▸ **Context budget** steps through
presets from 8k to 1M tokens, or Enter lets you type
any value (below 4k counts as auto) — models differ, and so do jobs. The
default, *auto*, is derived from the model's own window: the window minus
a reserve for the reply, at most 20k and at most a quarter of the window.
Compaction starts at 75 % of the budget.

The line shows a bar: green up to the point where compaction starts, amber up
to the budget, grey for the rest of the model's window. Set the budget lower to
keep responses cheap and quick, higher to let long missions run without
interruption. A project can have its own budget under Settings ▸ Project, and one session can
have its own (`session.context_budget_tokens`) through the session scope
in `/config`. Whether the context percentage in the header counts against your budget or
against the model's window is a Display setting (*Context % of
budget*).

## Predictive preload

Experimental, and off by default (Settings ▸ General ▸ **Predictive
preload**). Monix Agent watches what the agent reads over several missions of
a project. What it keeps returning to — a project memory fact it looks up
again and again, a file it opens in mission after mission — is handed over at
the start of the next mission, so the agent saves the lookup and the round trip
it would have cost. Files come as a short map with one-line hints, not as
content that could go stale; the few files that are read and almost never
edited may come with their content.

It pays off when your habits are stable and adds noise when they are not.
The technical lines it writes to the transcript are hidden unless you switch on
*Preload / restore lines* under Display.

## Memory lookups

With *PUM loading* on *map* (Settings ▸ General; the default is
*full*),
a mission starts with the standing rules of the project and a list of topics.
Everything else the agent looks up itself, with the memory tool, whenever the
task calls for it — so what it knows is something it asked for. On
*full* the whole memory is loaded upfront instead, which costs more on
every call. The search runs on your machine, on an embedding model you choose in
the settings — nothing about your project is sent anywhere for it.

Mid-mission the memory is searched again after an error or when the work moves
to a new area (`tui.pumDelta`, default on). It is a flag in
`tui-config.json` that Monix Desktop writes for you. A project can turn it
on or off for itself with *Look up memory mid-task*
in its project settings; empty inherits the global flag.

## Re-read dedup

If the agent reads the same unchanged file twice, the second copy is not
added again — a short note says the file is unchanged and already above. A long mission touches the same
handful of files repeatedly; without this, the same content accumulates in the
window several times over. Settings ▸ General ▸ **Re-read dedup**, on by
default.

## RTK token saver

Long shell output — test runs, build logs, directory listings — is mostly
noise to the model. With the RTK helper on your PATH, Monix Agent compresses it before
the model sees it. Settings ▸ General ▸ **RTK token saver**, on by
default; the installer brings the helper, and without it nothing is
compressed. It only handles the common developer commands it knows, and never
long-running ones such as servers or watchers.

## Prompt cache TTL

How long the provider keeps the conversation warm between calls. A longer
window survives you going for coffee — the next message is still cheap. It makes
the first write more expensive (twice the normal input price instead of 1.25
times), so it pays off when you work in bursts with pauses, and costs when you
work in one continuous run. Settings ▸ Advanced ▸ **Prompt cache
TTL**, *5m* by default. Only Anthropic models use it; other
providers manage their own caching.

## Watching it work

The session header shows how full the context is. When Monix Agent compacts, it
says so in the conversation. When it hides old tool output, the
*Context-trim notice* (Settings ▸ Display, off by default) says so and
why — switch it on if you want to see every decision; if one looks wrong to
you, **Trim old tool output at** under Settings ▸ Advanced is
where you change it.
