Skip to content
Guides

OpenClaw context and compaction

What the model sees, how to inspect it, and what happens when the window fills

6 min read

Context, in OpenClaw’s vocabulary, is everything sent to the model for one run, and it is bounded by the model’s context window. The docs give a beginner’s model of it: the system prompt OpenClaw builds, the conversation history, and the tool calls, results and attachments, and they are careful to say it is not memory, which lives on disk and is reloaded, but what is inside the window right now. Here is how to inspect it, what fills it, what compaction does when it nears the limit, and the settings that shape both.

Inspecting it

  • The status command shows how full the window is and the session settings; the usage command with tokens adds a per-reply footer.
  • The context list command shows what is injected and its rough size: the system prompt and its project-context share, each injected workspace file, the skills list, the tool list, and the tool schemas, which count toward context without appearing as text; the detail variant breaks it down per file, per tool schema and per skill, and the map variant draws a treemap of the session’s contributors.
  • The Control UI meter uses the last run’s prompt budget when it still matches the model and cap, leaving room for the compaction reserve; it is an estimate, and crossing it can trigger tool-result reduction or compaction.

Compaction

When a conversation approaches the limit, OpenClaw compacts older turns into a summary saved in the transcript and keeps the recent messages intact. It keeps assistant tool calls paired with their results when choosing the split point, accounts for Chinese, Japanese and Korean characters when estimating sizes, and hands the summarizer text rather than image pixels, with markers for omitted images. New configs default to a safeguard mode with stricter guardrails and a summary quality audit: required headings, pending asks and exact identifiers must survive in the stored summary, and if no attempt passes, compaction stops without writing anything and keeps the original history.

The full conversation history stays on disk. Compaction only changes what the model sees on the next turn.

Automatic and manual

  • Auto-compaction is on by default: it runs when the session nears the limit, or when the model returns a context-overflow error, in which case OpenClaw compacts and retries; dozens of provider-specific overflow strings are recognized.
  • Before compacting, OpenClaw reminds the agent to save important notes to its memory files, which is how durable context survives the summary; the status command counts compactions, and the logs show start and complete lines.
  • The compact command forces one, optionally with a focus instruction of up to 800 characters; manual compaction keeps a recent tail of about twenty thousand tokens by default, and proactive compaction can be disabled in config while overflow recovery and manual compaction stay available.

OpenClaw memory explained is where the notes go before a compaction, and OpenClaw usage tracking explains the token numbers the meter is built from.

What fills the window

The example breakdown in the docs is instructive: a system prompt near ten thousand tokens, tool schemas near eight thousand that never appear as text, a skills list, a tool list, and the workspace files, all before the first message. The OpenClaw system prompt explains how that system prompt is assembled and why its stable half sits above a cache boundary.

On Diali

On Diali the window is the model’s and the compaction is the runtime’s, both the same as the docs describe; what changes is that the model choice, and therefore the window size, comes from the managed catalog, and the credits meter shows what each turn cost. Hosted OpenClaw on Diali is the assistant.

  • Context is the window’s contents; memory is the disk.
  • Status, context list and detail show what fills it.
  • Compaction summarizes the old, keeps the recent, and never deletes the transcript.
Get started

Stop reading about it, build one

Set up an agent, pick a channel, and have it working inside the app you already keep open.