L Loach Docs
Ctrl K

Context usage & compaction

A slim context-usage bar sits just below the message box and shows how much of the model’s context window the chat is using. When a conversation grows long, Compact context frees space without throwing away your scrollback.

The context-usage bar

The bar appears once a chat has messages. It reports used / total tokens and a percentage, and turns amber from 70% and red from 90%. Click it for a popover that breaks the estimate down:

It’s an estimate, so actual counts vary by model. Messages and attachments are counted at about four characters per token; the system prompt, project instructions, memories and sources at about four per token for Latin-script text and about one per character for Chinese, Japanese and Korean. A reply’s thinking isn’t counted, since it’s never sent back to the model, and neither are the persona and tone. The window is the chat’s Context Length setting. An OpenAI-compatible server picks its own window, so on those chats the bar measures against an assumed 32,768 tokens (33k on the bar) unless the chat or its Space sets a Context Length - set it to your model’s window, and treat the percentage as a rough guide.

Expand context window at the bottom of the popover doubles this chat’s Context Length - for example from 8K to 16K - and a bigger window uses more VRAM. It’s offered on Ollama chats only, since an OpenAI-compatible server decides its window itself.

Compact context

Press Compact context in the bar’s popover, or use the /compact slash command. Loach asks the chat’s own model to summarise the older turns as short bullet points - your goals, decisions, key facts and open threads - and keeps that summary with the chat’s instructions. The four most recent messages stay as they are; everything before them is replaced, for the model, by the summary.

The original messages aren’t deleted. They stay in the transcript for scrollback above an Earlier messages compacted divider - click it to read the summary - but are dropped from what the model sees on the next turn, so the freed context goes to new conversation. Compacting again later folds the previous summary into the new one, so older context carries forward.

When you can compact

Where the summary lives

The summary is stored with the chat’s own instructions, so you can read - and edit - it in the Additional instructions box of the parameters panel, between the [Loach: earlier conversation summary] and [End of Loach summary] markers. It doesn’t count as an instruction, though: it rides along with whichever instructions apply - a Space’s, the chat’s own, or your global Custom instructions - so compacting a chat never switches those off. Setting or clearing instructions with /instructions keeps the summary in place.

Emptying the chat with /clear removes the summary along with the messages and keeps your own instructions; it isn’t allowed while the chat is being compacted. A fork keeps the summary, unless you fork from a reply before the last compacted turn: then the fork drops the summary and sends the turns it copied in full again.

Your transcript is safe

Compaction only changes what the model receives on the next turn. Nothing is removed from your side of the conversation, and you can keep scrolling back through everything that was said.

A compact copy without compacting

Export context in the chat header has its own Compact context switch: it summarises the whole conversation into a shorter Markdown export and leaves the chat untouched. See Import and export context.