Context is the information the agent uses to understand and respond to your messages. OpenClaw automatically loads relevant context, manages token usage, and compacts context when needed to stay within model limits.

What is Context?

Context includes:

  • Conversation History - Previous messages in the session
  • Memories - Relevant information from your workspace
  • System Prompts - Agent instructions and configuration
  • Tool Definitions - Available tools and their descriptions
  • Skills - Active skills and their context

Context Loading

Moltbot automatically loads context:

Automatic Loading

  • Session Context - Loads conversation history
  • Memory Search - Finds relevant memories
  • Tool Loading - Includes available tools
  • Skill Context - Loads active skill information

Relevance

The agent loads only relevant context:

  • Searches memories for related information
  • Includes recent conversation history
  • Loads tools that might be needed
  • Keeps context focused and efficient

Token Management

LLM models have context limits measured in tokens:

  • Token Limits - Each model has a maximum context size
  • Token Counting - Moltbot tracks token usage
  • Automatic Management - Stays within limits automatically

Token Usage

Tokens are used for:

  • System prompts
  • Conversation history
  • Memories
  • Tool definitions
  • Your messages
  • Agent responses

Context Compaction

When context approaches token limits, Moltbot compacts it:

How Compaction Works

  • Summarization - Old context summarized
  • Pruning - Less relevant information removed
  • Preservation - Important information kept
  • Automatic - Happens seamlessly

What Gets Compacted

  • Old conversation history
  • Less relevant memories
  • Redundant information

What's Preserved

  • Recent conversation
  • Important memories
  • System prompts
  • Active tool definitions

Session Context

Each session maintains its own context:

  • Main Session - Shared context across DMs
  • Group Sessions - Isolated context per group
  • Isolated Sessions - Separate context for specific needs

Context Isolation

Different sessions don't share context:

  • Groups have separate context
  • Isolated sessions are independent
  • Main session shares across DMs

Optimizing Context

For Better Performance

  • Keep Conversations Focused - Easier context management
  • Use Clear Messages - Better context understanding
  • Let Compaction Work - Trust automatic management

For Better Context

  • Build Memories - More memories = better context
  • Use Skills - Skills add relevant context
  • Maintain Workspace - Organized workspace helps

Context Best Practices

  • Trust Automatic Management - Compaction works well
  • Build Good Memories - Quality memories improve context
  • Use Clear Messages - Better context understanding
  • Let It Learn - Context improves over time
  • Monitor Token Usage - Check usage if needed

Learn More