OpenClawSkills
GitHub
Core Concepts β€’ TutorialHeader.readTime

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).

Tutorial.step

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.
Tutorial.step

Context Loading

OpenClaw uses smart loading strategies to keep agents focused and efficient:

Automatic Loading

Loads session history, tool definitions, and active skills by default.

Memory Retrieval

Scans memory for information relevant to the current query and injects it.

Tutorial.step

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
Tutorial.step

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

  1. Summarization: older parts of the conversation are summarized into a few dense paragraphs.
  2. Pruning: least relevant memories or redundant logs are removed.
  3. Preservation: recent messages, system instructions, and important memories are always kept intact.

Automatic and Seamless

Compression happens automatically in the background. You usually won't notice it except that the agent "remembers" the gist rather than exact wording of older messages.
Tutorial.step

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.

Tutorial.step

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.