Context
Context: what the model sees, how it is built, and how to inspect it
"Context" is **everything OpenClaw sends to the model for a run**. It is bounded by the model's **context window** (token limit).
What is Context?
Context is the LLM's "working memory". It includes:
- Conversation history: previous messages and interactions in the current session.
- Memory: relevant facts and information recalled from the workspace.
- System prompt: core instructions that define the agent's personality and behavior.
- Tool definitions: descriptions of available actions the agent can take.
- Skills: active skill sets and their specialized context.
Context Loading
OpenClaw uses smart loading strategies to keep agents focused and efficient:
Loads session history, tool definitions, and active skills by default.
Scans memory for information relevant to the current query and injects it.
Token Limits
Large language model (LLM) space is measured and limited in tokens. OpenClaw accurately tracks this usage to avoid errors.
What consumes tokens?
- System prompt
- Conversation history
- Memory
- Tool definitions
- User messages
- Agent responses
Context Compression
When the context window nears its limit, OpenClaw runs compression to make room for new messages without losing important context.
How it works
- Summarization: older parts of the conversation are summarized into a few dense paragraphs.
- Pruning: least relevant memories or redundant logs are removed.
- Preservation: recent messages, system instructions, and important memories are always kept intact.
Automatic and Seamless
Session Types
Each session maintains its own independent context thread:
- Direct Messages
Context shared across all DMs with the owner.
- Group Chats
Isolated context for a single group chat. Messages here don't leak to other groups or DMs.
- Subagent Sessions
Standalone temporary sessions used for specific subtasks or specialized agents.
Context Best Practices
Clear messages: use specific language so the agent can retrieve the most relevant memories.
Build memory: high-quality memories in your workspace provide better supporting context.
Focused conversations: keeping to a thread or topic makes context management and compression more efficient.
Trust compression: let the automatic system handle cleanup; it's optimized for high retention.