OpenClaw Assistant Setup
OpenClaw Assistant Setup
Section titled “OpenClaw Assistant Setup”The OpenClaw Assistant is the AI agent that processes your messages and generates responses. This guide covers setting up and configuring the assistant.
What is the OpenClaw Assistant?
Section titled “What is the OpenClaw Assistant?”The OpenClaw Assistant is powered by Pi, a coding agent designed for autonomous task execution. Unlike simple chatbots, Pi can:
- Write and execute code
- Browse the web for information
- Manipulate files and directories
- Run terminal commands
- Integrate with external APIs
Agent Architecture
Section titled “Agent Architecture”User Message → Gateway → Pi Agent → Tool Execution → ResponseThe agent operates in RPC mode, communicating with the Gateway via secure local connections.
Prerequisites
Section titled “Prerequisites”Before setting up the assistant:
- OpenClaw Gateway running - See Getting Started
- Pi agent installed - Usually bundled with OpenClaw
- API keys - For AI models (Claude, GPT-4, etc.)
Installation
Section titled “Installation”Method 1: Bundled Pi (Recommended)
Section titled “Method 1: Bundled Pi (Recommended)”Pi is included with OpenClaw by default:
# Verify Pi is availableopenclaw agent status
# Test Pi connectionopenclaw agent testMethod 2: Separate Pi Installation
Section titled “Method 2: Separate Pi Installation”For custom Pi setups:
# Install Pi separatelynpm install -g @badlogic/pi
# Configure OpenClaw to use external Piopenclaw config set agents.default.rpc.host 127.0.0.1openclaw config set agents.default.rpc.port 8080Configuration
Section titled “Configuration”Basic Agent Setup
Section titled “Basic Agent Setup”Edit ~/.openclaw/openclaw.json:
{ agents: { default: { type: "pi", rpc: { host: "127.0.0.1", port: 8080, timeout: 30000 }, model: "claude-3.5-sonnet", maxTokens: 4096, temperature: 0.7 } }}Model Configuration
Section titled “Model Configuration”Claude (Anthropic)
Section titled “Claude (Anthropic)”{ agents: { default: { model: "claude-3.5-sonnet", anthropic: { apiKey: "your-anthropic-api-key", maxTokens: 4096 } } }}OpenAI GPT
Section titled “OpenAI GPT”{ agents: { default: { model: "gpt-4", openai: { apiKey: "your-openai-api-key", baseURL: "https://api.openai.com/v1", maxTokens: 4096 } } }}Local Models (Ollama)
Section titled “Local Models (Ollama)”{ agents: { default: { model: "llama3.1", ollama: { host: "127.0.0.1", port: 11434, model: "llama3.1:8b" } } }}Agent Capabilities
Section titled “Agent Capabilities”File System Operations
Section titled “File System Operations”Pi can read, write, and manipulate files:
# User: "Create a new Python script that calculates fibonacci"# Pi will:# 1. Create fibonacci.py# 2. Write the implementation# 3. Test the script# 4. Report resultsWeb Browsing
Section titled “Web Browsing”Pi can browse the web for information:
# User: "Find the latest React documentation"# Pi will:# 1. Open browser# 2. Navigate to react.dev# 3. Extract relevant information# 4. Summarize findingsTerminal Commands
Section titled “Terminal Commands”Pi can execute terminal commands:
# User: "Check system disk usage"# Pi will:# 1. Run `df -h`# 2. Parse output# 3. Present readable summaryAPI Integration
Section titled “API Integration”Pi can interact with external APIs:
# User: "Post a message to our Slack channel"# Pi will:# 1. Use Slack API# 2. Authenticate with stored token# 3. Send the message# 4. Confirm deliverySecurity Considerations
Section titled “Security Considerations”Sandboxing
Section titled “Sandboxing”For security, consider running Pi in a sandboxed environment:
# Docker sandbox (recommended)docker run -it --rm \ -v $(pwd):/workspace \ --network=none \ openclaw/pi-sandbox
# Or use OpenClaw's built-in sandboxingopenclaw config set agents.default.sandbox.enabled truePermission Controls
Section titled “Permission Controls”Restrict what the agent can access:
{ agents: { default: { permissions: { fileSystem: { allowedPaths: ["/workspace", "/tmp"], deniedPaths: ["/etc", "/usr/bin"] }, network: { allowedDomains: ["api.github.com", "docs.example.com"], denyInternet: false }, commands: { allowed: ["python", "node", "git"], denied: ["rm", "sudo", "chmod"] } } } }}Multi-Agent Setup
Section titled “Multi-Agent Setup”OpenClaw supports multiple agents for different tasks:
{ agents: { coding: { type: "pi", model: "claude-3.5-sonnet", specialization: "coding" }, research: { type: "pi", model: "gpt-4", specialization: "research" }, chat: { type: "pi", model: "claude-3-haiku", specialization: "conversation" } }, routing: { default: "chat", code: "coding", research: "research" }}Monitoring and Logging
Section titled “Monitoring and Logging”Agent Logs
Section titled “Agent Logs”# View agent activityopenclaw agent logs
# Follow logs in real-timeopenclaw agent logs --follow
# Filter by sessionopenclaw agent logs --session user123Performance Metrics
Section titled “Performance Metrics”# Check agent performanceopenclaw agent stats
# Response times, token usage, error ratesopenclaw agent metricsTroubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Agent not responding
# Check agent statusopenclaw agent status
# Restart agentopenclaw agent restart
# Check RPC connectionopenclaw agent testModel errors
# Verify API keysopenclaw config show agents.default.anthropic.apiKey
# Test model connectionopenclaw agent test --model claude-3.5-sonnetPermission denied
# Check agent permissionsopenclaw config show agents.default.permissions
# Reset permissions to defaultsopenclaw agent permissions resetDebug Mode
Section titled “Debug Mode”Enable detailed logging for troubleshooting:
# Enable debug modeopenclaw config set logging.level debug
# Run agent with debug outputopenclaw agent --debugAdvanced Configuration
Section titled “Advanced Configuration”Custom System Prompts
Section titled “Custom System Prompts”{ agents: { default: { systemPrompt: "You are a helpful coding assistant. Always provide working code examples.", temperature: 0.3, maxTokens: 8192 } }}Tool Configuration
Section titled “Tool Configuration”{ agents: { default: { tools: { fileSystem: true, webBrowser: true, terminal: true, api: { enabled: true, timeout: 10000 } } } }}Memory and Context
Section titled “Memory and Context”{ agents: { default: { memory: { maxContextLength: 10000, retainHistory: true, summaryThreshold: 8000 } } }}Best Practices
Section titled “Best Practices”- Start with restrictive permissions - Gradually expand as needed
- Use sandboxing - Especially for untrusted code execution
- Monitor token usage - Set limits to control costs
- Regular backups - Backup configuration and important data
- Update regularly - Keep Pi and OpenClaw updated
Next Steps
Section titled “Next Steps”- Configure specific channels - Set up messaging platforms
- Explore routing rules - Advanced agent routing
- Set up monitoring - Track agent performance
- Security hardening - Production security setup
Your OpenClaw Assistant is now ready to help you with coding, research, and automation tasks! 🤖