Understanding Context: What the Model Sees and How to Inspect It
Learn what context means in OpenClaw, how it differs from memory, and how to inspect its contents using commands like /status and /context list. Essential for developers managing model input.
Read this when
- You want to understand what "context" means in OpenClaw
- You are debugging why the model "knows" something (or forgot it)
- You want to reduce context overhead (/context, /status, /compact)
"Context" refers to everything OpenClaw provides to the model during a single run. Its size is constrained by the model's context window, measured in tokens.
A beginner's way to think about it:
- System prompt (assembled by OpenClaw): includes rules, tool and skill lists, time and runtime data, plus workspace files that are injected.
- Conversation history: the back-and-forth of your messages and the assistant's replies within this session.
- Tool calls/results + attachments: command outputs, file contents, images, audio, and similar data.
Context is not the same as "memory". Memory can be saved to disk and retrieved later. Context is what currently occupies the model's window.
Quick start (inspect context)
/status→ shows a quick "how full is my window?" indicator along with session settings./context list→ displays what has been injected and approximate sizes (per file and total)./context detail→ provides a more detailed breakdown: per-file data, per-tool schema sizes, per-skill entry sizes, system prompt size, and the number of compactable transcript messages./context map→ renders a WinDirStat-style treemap image of all tracked context contributors in the current session./usage tokens→ appends a per-reply usage footer to normal responses./compact→ condenses older history into a compact entry to reclaim window space.
See also: Slash commands, Token use & costs, Compaction.
Example output
The actual values depend on the model, provider, tool policies, and the contents of your workspace.
/context list
🧠 Context breakdown
Workspace: <workspaceDir>
Bootstrap max/file: 12,000 chars
Sandbox: mode=non-main sandboxed=false
System prompt (run): 38,412 chars (~9,603 tok) (Project Context 23,901 chars (~5,976 tok))
Injected workspace files:
- AGENTS.md: OK | raw 1,742 chars (~436 tok) | injected 1,742 chars (~436 tok)
- SOUL.md: OK | raw 912 chars (~228 tok) | injected 912 chars (~228 tok)
- TOOLS.md: TRUNCATED | raw 54,210 chars (~13,553 tok) | injected 20,962 chars (~5,241 tok)
- IDENTITY.md: OK | raw 211 chars (~53 tok) | injected 211 chars (~53 tok)
- USER.md: OK | raw 388 chars (~97 tok) | injected 388 chars (~97 tok)
- HEARTBEAT.md: MISSING | raw 0 | injected 0
- BOOTSTRAP.md: OK | raw 0 chars (~0 tok) | injected 0 chars (~0 tok)
Skills list (system prompt text): 2,184 chars (~546 tok) (12 skills)
Tools: read, edit, write, exec, process, browser, message, sessions_send, …
Tool list (system prompt text): 1,032 chars (~258 tok)
Tool schemas (JSON): 31,988 chars (~7,997 tok) (counts toward context; not shown as text)
Tools: (same as above)
Session tokens (cached): 14,250 total / ctx=32,000
/context detail
🧠 Context breakdown (detailed)
…
Top skills (prompt entry size):
- frontend-design: 412 chars (~103 tok)
- oracle: 401 chars (~101 tok)
… (+10 more skills)
Top tools (schema size):
- browser: 9,812 chars (~2,453 tok)
- exec: 6,240 chars (~1,560 tok)
… (+N more tools)
/context map
Sends an image built from the most recent cached run report and the session transcript. If no run report exists yet in the session for a normal message, /context map returns an unavailable message instead of generating an estimate. The area of each rectangle is proportional to the number of tracked prompt characters:
- conversation transcript (user messages, assistant replies, tool results, compaction summaries), plus per-turn runtime context and hook prompt additions that reach only the model
- injected workspace files
- base system prompt text
- skill prompt entries
- tool JSON schemas
The conversation group expands as the session continues, so the map changes with each turn. After compaction, it collapses into a single summaries tile.
/context list, /context detail, and /context json can still request an on-demand estimate even when no run report is cached.
What counts toward the context window
Every piece of data the model receives is counted, including:
- System prompt (all sections).
- Conversation history.
- Tool calls and their results.
- Attachments and transcripts (images, audio, files).
- Compaction summaries and pruning artifacts.
- Provider "wrappers" or hidden headers (invisible to you but still counted).
How OpenClaw builds the system prompt
The system prompt is owned by OpenClaw and is regenerated for every run. It contains:
- A list of tools with short descriptions.
- A list of skills (metadata only; see below).
- The workspace location.
- The current time (UTC, plus the user's converted time if configured).
- Runtime metadata (host, OS, model, thinking mode).
- Injected workspace bootstrap files under Project Context.
For a complete breakdown: System Prompt.
Injected workspace files (Project Context)
By default, OpenClaw injects a fixed set of workspace files when they exist:
AGENTS.mdSOUL.mdTOOLS.mdIDENTITY.mdUSER.mdHEARTBEAT.mdBOOTSTRAP.md(only on the first run)
Large files are truncated individually using agents.defaults.bootstrapMaxChars (default 20000 characters). OpenClaw also applies a total bootstrap injection limit across all files with agents.defaults.bootstrapTotalMaxChars (default 60000 characters). /context displays raw versus injected sizes and indicates whether truncation occurred.
When truncation happens, the runtime can insert a warning block into the prompt under Project Context. Control this with agents.defaults.bootstrapPromptTruncationWarning (off, once, always; default always).
Skills: injected vs loaded on-demand
The system prompt includes a compact skills list (name, description, and location). This list carries real overhead.
Skill instructions are not included automatically. The model is expected to read the skill's SKILL.md only when needed.
Tools: there are two costs
Tools affect context in two ways:
- Tool list text in the system prompt (visible as "Tooling").
- Tool schemas (JSON). These are sent to the model so it can invoke tools. They consume context even though you never see them as plain text.
/context detail breaks down the largest tool schemas so you can identify what dominates.
Commands, directives, and "inline shortcuts"
Slash commands are processed by the Gateway. They behave in a few different ways:
- Standalone commands: a message consisting only of
/...runs as a command. - Directives:
/think,/fast,/verbose,/trace,/reasoning,/elevated,/exec,/model,/queueare removed before the model sees the message.- Messages that are only directives persist session settings.
- Inline directives within a normal message act as per-message hints.
- Inline shortcuts (only from allowlisted senders): certain
/...tokens inside a normal message can execute immediately (for example, "hey /status"), and are stripped before the model sees the remaining text.
Details: Slash commands.
Sessions, compaction, and pruning (what persists)
The deciding factor for what carries over between messages depends on which mechanism is in use:
- Normal history stays in the session transcript until policy decides to compact or prune it.
- Compaction inserts a summary into the transcript while leaving recent messages unchanged.
- Pruning removes old tool results from the in-memory prompt to free up context window capacity, but it does not alter the session transcript itself. The complete history remains viewable on disk.
Documentation: Session, Compaction, Session pruning.
Out of the box, OpenClaw relies on its default legacy context engine for both assembly and compaction. When you install a plugin that offers kind: "context-engine" and choose it with plugins.slots.contextEngine, OpenClaw hands off context assembly, /compact, and the related lifecycle hooks for subagent context to that engine instead. ownsCompaction: false does not automatically revert to the older engine; the active engine must still implement compact() correctly. Refer to Context Engine for the complete pluggable interface, lifecycle hooks, and configuration details.
What /context actually reports
/context favors the most recent run-built system prompt report whenever one exists:
System prompt (run)= taken from the last embedded (tool-capable) run and saved in the session store.System prompt (estimate)= generated on the fly when no run report is present (or when running through a CLI backend that does not produce the report).
In either case, it reports sizes and the top contributors; it does not output the full system prompt or tool schemas. In detailed mode, it also compares the session transcript using the same real-conversation message predicate that compaction uses, making it easier to tell high prompt or cache usage apart from compactable conversation history.
Related
-
Context engine, Inject custom context through plugins.
-
Compaction, Summarize lengthy conversations so they fit within the model window.
-
System prompt, How the system prompt is constructed and what it injects on each turn.
-
Agent loop, The complete agent execution cycle from incoming message to final response.