OpenClaw Configuration Deep Dive
OpenClaw Configuration Deep Dive
OpenClaw is the backbone of my AI agent setup. After months of tweaking, here's what I've learned about getting the most out of it.
Architecture Overview
OpenClaw runs as a Gateway daemon on your server, providing:
- Multi-provider LLM routing
- Tool/ skill system for agent actions
- Session management
- Various channel integrations (Telegram, Discord, etc.)
Core Configuration
The main config lives at ~/.openclaw/config.yml:
gateway:
bind: "0.0.0.0:18789"
auth:
enabled: true
tokens:
- name: "main"
token: "sk-your-token-here"
model:
providers:
- name: "lmstudio"
type: "openai"
endpoint: "http://100.107.153.118:1234/v1"
model: "unsloth/qwen3.5-9b@q6_k"
priority: 1
- name: "openrouter"
type: "openrouter"
api_key: "sk-or-your-key"
default_model: "anthropic/claude-sonnet-4-6"
priority: 2
Model Routing
The priority system is clever:
- OpenClaw tries providers in priority order
- If primary fails (rate limit, timeout), it falls back
- You can also specify model per-conversation
I've set up my local LM Studio as primary for routine tasks, with OpenRouter as fallback for complex reasoning.
Skills System
Skills extend what agents can do. They're defined in ~/.openclaw/skills/:
skills/
├── calculator/ # Math operations
├── web-search/ # Brave Search API
├── code-interpreter/ # Run code
└── custom/ # Your own skills
├── SKILL.md
└── scripts/
Each skill has a SKILL.md that describes:
- When to use
- Input/output format
- Implementation details
Session Management
Sessions are persistent conversation contexts:
session:
storage: "sqlite" # or "redis" for clustering
db_path: "~/.openclaw/sessions.db"
max_history: 50 # messages per session
ttl: 86400 # 24 hours
For long-running agents, I recommend external session storage.
Environment Variables
Don't hardcode secrets! Use env vars:
model:
providers:
- name: "openrouter"
api_key: "$ENV_OPENROUTER_API_KEY" # reads from env
Troubleshooting
Common issues and fixes:
"No available model" error
# Check LM Studio is running
curl http://100.107.153.118:1234/v1/models
# Check OpenClaw logs
journalctl -u openclaw -f
High latency
- Switch to local models for simple tasks
- Reduce context window
- Enable response streaming
Rate limits
- Implement exponential backoff
- Queue requests
- Use multiple API keys rotation
Production Checklist
Before going to production:
- Enable authentication
- Set up monitoring/logging
- Configure rate limiting
- Set up backup for sessions
- Test failover between providers
- Document your configuration
Conclusion
OpenClaw is incredibly flexible. The config above is just a starting point — read the docs, experiment, and find what works for your use case.