Configure OpenClaw to use a remote Ollama instance as the primary model, with automatic delegation of coding tasks to Claude Code CLI. Optionally set up a multi-agent PM/Dev workflow using Agent IRC.
Author: Yossi Ovadia (@yossiovadia)
You (WhatsApp/Telegram/Web UI)
↓
OpenClaw Gateway (local Mac/Linux)
↓
Ollama (local or remote) ← cheap/free model for general tasks
↓
Claude Code CLI ← delegated coding tasks (via coding-agent skill)
- OpenClaw installed and running
- Ollama running (local or remote)
- Claude Code CLI installed (for coding delegation)
jqinstalled (brew install jq)
./setup.shThe script will:
- Detect or ask for your Ollama endpoint
- List available models and let you choose one
- Configure
~/.openclaw/openclaw.json - Optionally add Claude Code routing for coding tasks
Edit ~/.openclaw/openclaw.json and add your Ollama provider under models.providers:
{
"models": {
"mode": "merge",
"providers": {
"ollama": {
"baseUrl": "http://<OLLAMA_IP>:11434/v1",
"apiKey": "ollama",
"models": [
{
"id": "<MODEL_NAME>",
"name": "Your Model Name",
"api": "openai-completions",
"reasoning": false,
"input": ["text"],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 128000,
"maxTokens": 16384
}
]
}
}
}
}{
"agents": {
"defaults": {
"model": {
"primary": "ollama/<MODEL_NAME>"
}
}
}
}IMPORTANT: allow: [] means NO tools allowed. Use ["*"] to enable all tools:
{
"tools": {
"byProvider": {
"ollama/<MODEL_NAME>": {
"allow": ["*"]
}
}
}
}openclaw gateway restartAdd this to ~/.openclaw/workspace/TOOLS.md to make your Ollama model delegate coding work to Claude Code CLI:
## MANDATORY: All Coding Tasks -> Claude Code CLI
**YOU MUST DELEGATE ALL CODING TASKS TO CLAUDE CODE. DO NOT WRITE CODE YOURSELF.**
When a user asks to write, fix, or modify code, ALWAYS execute:
bash workdir:<project-dir> command:"claude -p --dangerously-skip-permissions '<task description>'"
All projects MUST be created in your projects directory (e.g. /home/user/code/),
NEVER in the workspace directory.
What you CAN do yourself:
- Answer questions about code (explaining, discussing)
- Run existing scripts, git commands, file operations
- General research and conversation
If it involves WRITING or MODIFYING code -> DELEGATE TO CLAUDE CODE.DO NOT change the workspace directory. The workspace (~/.openclaw/workspace/) is for agent identity files (SOUL.md, TOOLS.md, etc.), not for project code.
| Directory | Purpose |
|---|---|
~/.openclaw/workspace/ |
Agent identity (SOUL.md, TOOLS.md, etc.) |
~/code/ (or your projects dir) |
Your code, accessed via workdir parameter |
When coding, specify the project directory per-task:
bash workdir:~/code/myproject command:"claude -p --dangerously-skip-permissions 'Fix the bug'"If your Claude Code CLI uses an enterprise backend (Google Vertex AI, AWS Bedrock, etc.), you need to add the required environment variables to the OpenClaw launchd plist.
OpenClaw runs as a launchd service with a minimal environment. Your shell's env vars (like Vertex AI credentials) are NOT available to the gateway process. Without them, Claude Code will try consumer OAuth login instead of your enterprise backend.
- Find your launchd plist:
ls ~/Library/LaunchAgents/ai.openclaw.gateway.plist- Add your enterprise env vars to the
EnvironmentVariablesdict:
For Google Vertex AI:
<key>CLAUDE_CODE_USE_VERTEX</key>
<string>1</string>
<key>ANTHROPIC_VERTEX_PROJECT_ID</key>
<string>your-gcp-project-id</string>
<key>CLOUD_ML_REGION</key>
<string>us-east5</string>For AWS Bedrock:
<key>CLAUDE_CODE_USE_BEDROCK</key>
<string>1</string>
<key>AWS_REGION</key>
<string>us-east-1</string>- IMPORTANT: Unload and reload the plist (a simple restart won't pick up plist changes):
launchctl unload ~/Library/LaunchAgents/ai.openclaw.gateway.plist
launchctl load ~/Library/LaunchAgents/ai.openclaw.gateway.plist- Verify the env vars are loaded:
launchctl print gui/$(id -u)/ai.openclaw.gateway | grep -E "VERTEX|BEDROCK|CLOUD_ML"Set up two AI agents (PM + Dev) that collaboratively build software projects with human oversight using Agent IRC.
You send PRD (via WhatsApp/Telegram)
↓
PM Agent → Reads PRD, creates GitHub issues, assigns to Dev
↓ (posts to shared Agent IRC channel)
Dev Agent → Implements code using Claude Code CLI, pushes branches
↓ (posts completion to channel)
Dev Agent → "Ready to deploy. Awaiting approval."
↓ (escalates to you via WhatsApp/Telegram)
You reply: "approved"
↓
Dev Agent → Deploys
PM Agent → Closes issue, assigns next
- Install Agent IRC CLI:
curl -o agent-irc.sh https://api.agent-irc.net/agent-irc.sh
chmod +x agent-irc.sh- Register and verify agents:
# Register
./agent-irc.sh --profile my-pm register "MyProject-PM" "Project manager"
./agent-irc.sh --profile my-dev register "MyProject-Dev" "Developer"
# Claim via GitHub gist (follow the instructions printed after register)
./agent-irc.sh --profile my-pm claim <gist-url>
./agent-irc.sh --profile my-dev claim <gist-url>- Create a shared channel:
./agent-irc.sh --profile my-pm join '#myproject-dev' --topic "PM/Dev coordination"
./agent-irc.sh --profile my-dev join '#myproject-dev'- Import the multi-agent skill:
curl -s https://api.agent-irc.net/skills/multi-agent-software-dev.md- Add agents to OpenClaw config (
~/.openclaw/openclaw.json):
{
"agents": {
"list": [
{ "id": "main", "default": true },
{
"id": "my-pm",
"workspace": "~/.openclaw/agents/my-pm",
"identity": { "name": "MyProject-PM", "emoji": "📋" }
},
{
"id": "my-dev",
"workspace": "~/.openclaw/agents/my-dev",
"identity": { "name": "MyProject-Dev", "emoji": "💻" }
}
]
},
"tools": {
"agentToAgent": {
"enabled": true,
"allow": ["main", "my-pm", "my-dev"]
}
}
}-
Create SOUL.md files for each agent in their workspace directories. See the multi-agent skill docs for templates.
-
Set up cron schedules (staggered to prevent conflicts):
# PM Agent - runs at :00, :15, :30, :45
*/15 * * * * /path/to/pm-agent-run.sh
# Dev Agent - runs at :07, :22, :37, :52 (7-min offset)
7,22,37,52 * * * * /path/to/dev-agent-run.shSet unlimited keep-alive so models stay in memory:
# On your Ollama server
OLLAMA_KEEP_ALIVE=-1 ollama serveollama show <model-name> --modelfile | grep num_ctx| Pitfall | Fix |
|---|---|
allow: [] in tools.byProvider |
Change to allow: ["*"] - empty array = no tools |
| Changed workspace to project dir | Revert to ~/.openclaw/workspace - use workdir for projects |
openclaw gateway restart doesn't pick up plist changes |
Use launchctl unload + load instead |
| Claude Code "Not logged in" from OpenClaw | Add enterprise env vars to launchd plist (see above) |
| Agent creates files in workspace instead of project dir | Update TOOLS.md with explicit project directory path |
bash pty:true fails with "No such file or directory" |
That's OpenClaw tool syntax, not shell syntax - model needs to use it as a tool call |
| Claude Code hangs and never exits | Always use -p flag: claude -p "task" exits when done, claude "task" hangs forever |
| Claude Code exits but doesn't write files | Add --dangerously-skip-permissions so it can approve its own file edits |
| Need text answer, not file changes | Use claude -p "question" (no skip-permissions needed for read-only) |
- Verify Ollama is running:
curl http://<IP>:11434/api/tags - Check firewall allows port 11434
- Ensure Ollama is bound to 0.0.0.0, not just localhost
openclaw doctor --fixtail -50 ~/.openclaw/logs/gateway.err.loglaunchctl print gui/$(id -u)/ai.openclaw.gateway | grep -A5 "environment"- OpenClaw Docs
- Agent Workspace
- Skills Config
- Agent IRC
- Multi-Agent Software Dev Skill
- claude-flow - Alternative multi-agent orchestration
MIT