Skip to content
LoopCodeDocs

Concepts

Context and compaction

How LoopCode manages the model's context window across long sessions — what fills it, how old output is cleared, automatic and manual compaction, and side questions that stay out of later context.

The context window

Everything the model knows in a turn — your messages, its answers, the files it read, the commands it ran — has to fit in its context window: up to about a million tokens, depending on the model. A coding agent's context is dominated by tool output, so LoopCode works to keep only what still matters.

See how full it is:

  • In the terminal, the footer shows a context meter; /context breaks down what fills the window; /status shows the session's token usage.
  • In the desktop app, the meter under the composer shows it; click it for details.

The agent can check this itself, and starts a fresh context at a natural boundary — a phase finished, a long investigation done — rather than waiting to be squeezed.

Clearing old tool output

Once the model has read a file or a command's output and acted on it, keeping the full text costs tokens on every later turn. LoopCode clears the oldest tool results long before the window is under pressure. They are replaced by a placeholder, not deleted: the model knows the call happened and can read the output again if it needs it. The full history stays on disk either way; only what is sent to the model shrinks.

Compaction

When the window fills, LoopCode compacts the conversation automatically: the history is summarised, and the next turn starts from the summary.

Compact yourself at a good moment, and say what to keep:

/compact keep the migration plan and the list of failing tests

Your next message starts from the summary. /context shows the room it freed. A PreCompact hook can run before either kind of compaction.

Side questions

Two commands answer without adding anything to the conversation:

/btw what does the --frozen-lockfile flag do again?
/recap

/btw asks something on the side; /recap summarises the conversation so far. Neither answer is kept, so neither costs context later.

Keep the main thread light

  • Subagents read in their own context windows and return only a report. Ask for an Explore agent when a question needs a lot of reading. See Subagents and background tasks.
  • Skills cost one line each until they are used; the instructions load only when a task calls for them. See Skills and commands.
  • MCP tools are listed by name and loaded on demand, so connecting many servers does not fill the window.
  • One task per conversation. Start a new one (/new) when the topic changes. Lasting facts carry over through memory.

Past work

LoopCode can search earlier conversations in the project — their logs, plans and walkthroughs — when it needs to recall how something was done before.