Context compaction
When a long task approaches the model's context-window limit, Mogick summarizes earlier conversation and retains recent messages verbatim so work can continue. The complete session history remains stored locally; compaction changes only the context sent to the model on subsequent turns.
When to use
Automatic compaction is always enabled. It runs during request preparation when the context exceeds approximately 70% of the model's window. You can also compact manually when:
- The context indicator in the sidebar is approaching its limit.
- The conversation is long and you are about to start a new task phase.
- The model repeatedly refers to outdated details and you want to refocus the context.
/compact/compact must be the only content in the message and can run only while the session is idle. It will not start during model generation, tool execution, or another compaction.
What happens
Mogick generates a summary during compaction. When it succeeds:
- The TUI sidebar refreshes the context-window usage.
- An ACP host receives a new
usage_updateevent. - The next request uses the compacted summary plus recent messages in their original form.
- Original session history is not deleted.
If compaction fails, the current operation ends with an explicit error; Mogick never silently truncates history.
How it works
Before each model request, Mogick assembles in sequence:
| Layer | Content |
|---|---|
| System and runtime information | System prompts, tools, permissions, plans, memories, MCP, and project instructions |
| Compacted summary | Older history summarized with the handoff information needed to continue the task |
| Recent original messages | User, assistant, and tool messages retained verbatim after the summary |
| Current input | The current user message and attachments |
When the context approaches the limit again, Mogick compacts the existing summary together with newer history instead of reprocessing the complete original conversation. This allows long sessions to continue across multiple compactions.
The summary prioritizes task goals, decisions, file changes, unfinished work, constraints, and important errors. Repetition and intermediate details from completed work may be omitted. When exact wording matters, inspect the session history or reread the source file instead of relying only on the summary.
How compaction differs from other features
| Feature | What it affects | Deletes original history |
|---|---|---|
| Context compaction | Subsequent model input | No |
Checkpoint / /rewind | Workspace and/or session-history state | May roll it back |
| L3 Memory | Cross-session retrieval and accumulation | No |
/new | Create a new independent session | No |
Input boundary
A single user message, including attachment references, is limited to 1 MiB. This limit is independent of context compaction. Split very large inputs, narrow the referenced range, or let the agent read files on demand; /compact cannot bypass the per-message limit.
If the model does not report a context-window limit, the sidebar still shows token usage but may not display a percentage.