AI Agent

Understand the OpenClaw AI Agent concept, how agents work, and how to configure agent behavior.

What is an AI Agent?

An AI Agent in OpenClaw is an autonomous entity that can receive messages, process them using AI models, and respond through connected channels. Unlike simple chatbots, agents support:

  • Tool use — Call external APIs, run code, and interact with services
  • Sessions — Maintain isolated conversation contexts per sender
  • Memory — Store and recall information across conversations
  • Multi-agent routing — Route messages to specialized agents based on context

How Agents Work

User Message → Gateway → Message Router → Agent → AI Model → Response

                                     Tools / Memory
  1. A message arrives through a channel (WhatsApp, Telegram, etc.)
  2. The Gateway passes it to the message router
  3. The router selects the appropriate agent based on workspace rules
  4. The agent processes the message using its configured AI model
  5. The agent may call tools, access memory, or route to sub-agents
  6. The response flows back through the channel

Agent Configuration

Agents are configured in ~/.openclaw/openclaw.json:

{
  "agents": {
    "default": {
      "provider": "openai",
      "model": "gpt-4o",
      "systemPrompt": "You are a helpful assistant.",
      "temperature": 0.7,
      "maxTokens": 4096
    }
  }
}

Key Configuration Options

OptionDescriptionDefault
providerAI model provider (openai, anthropic, ollama, etc.)openai
modelModel namegpt-4o
systemPromptSystem prompt for agent behavior
temperatureResponse creativity (0-2)0.7
maxTokensMaximum response length4096

Multi-Agent Routing

OpenClaw supports multiple agents with workspace isolation:

{
  "agents": {
    "coder": {
      "provider": "anthropic",
      "model": "claude-sonnet-4-20250514",
      "systemPrompt": "You are an expert programmer."
    },
    "writer": {
      "provider": "openai",
      "model": "gpt-4o",
      "systemPrompt": "You are a creative writer."
    }
  },
  "routing": {
    "default": "coder",
    "rules": [
      {
        "match": "write|story|blog",
        "agent": "writer"
      }
    ]
  }
}

Sessions

Sessions maintain conversation history per sender:

  • Direct chats — Multiple messages from the same sender share one session
  • Group chats — Each group has an isolated session
  • Session reset — Send /reset or configure auto-expiry

Tools

Agents can use tools to interact with external systems:

  • File system access
  • Web browsing
  • API calls
  • Code execution
  • Database queries

Next Steps