Context and Output Compaction
Long conversations and large tool outputs both eat context. Wayland Core handles each with a separate mechanism: automatic context compaction keeps the conversation under the model’s window, and output compaction trims what tool results cost before they enter the context.
Context compaction (automatic)
Section titled “Context compaction (automatic)”Context compaction runs on its own in three tiers. You do not call it directly.
| Tier | Trigger | Method | LLM call |
|---|---|---|---|
| Microcompact | Too many old tool results, or a long gap | Clears old Read/Bash/Grep/Glob/Write/Edit results, keeping the most recent | No |
| Autocompact | Input tokens approach the window | The model summarizes the conversation, history is replaced with a boundary marker | Yes |
| Emergency | Input tokens near the absolute limit | Blocks further calls and asks you to start fresh | No |
Defaults live in [compact]. Microcompact keeps the 5 most recent tool results; autocompact triggers around context_window - output_reserve - autocompact_buffer. A circuit breaker stops retrying autocompact after a set number of failures.
[compact]enabled = truecontext_window = 200000output_reserve = 20000autocompact_buffer = 13000emergency_buffer = 3000micro_keep_recent = 5Output compaction (you control this)
Section titled “Output compaction (you control this)”Output compaction post-processes tool output to cut tokens. Three levels run from lightest to heaviest:
off: no change.safe(default): strip ANSI codes, merge blank lines, collapse carriage-return progress bars.full: everything insafe, plus folding repeated lines and compacting JSON indentation.
Set it per run:
wayland-core --compaction full "Run the test suite and report failures"TOON encoding
Section titled “TOON encoding”With full compaction you can turn on TOON, which encodes uniform JSON arrays as compact tables. It is a session-level choice and cannot change mid-conversation:
wayland-core --compaction full --toon "List the users table as JSON"[compact]compaction = "safe"toon = falseIn --json-stream mode a host can change the level at runtime with a set_config command carrying a new compaction value.