Patches for OpenClaw to enable local LLM persona support via Ollama.
By default, OpenClaw is designed for cloud APIs (Claude, GPT-4, etc.). These patches make it work well with local models by:
- Forcing a compact system prompt so it fits in a small context window
- Moving your persona definition (
SOUL.md) to the top of the system prompt - Disabling streaming (Ollama compatibility)
- Writing Heartbeat observations to daily memory files automatically
Tested with: OpenClaw v2026.3.2 + Ollama qwen2.5:14b
- OpenClaw installed via npm (
sudo npm install -g openclaw) - Ollama installed and running with at least one model pulled
- OpenClaw onboarding completed (
openclaw onboard)
sudo bash apply_patches.shThat's it. The script will:
- Check your OpenClaw version
- Find the correct dist files automatically
- Back up your existing
SOUL.md(if any) - Install the default persona template as
SOUL.md - Apply all patches
- Restart the OpenClaw gateway service
The script installs templates/SOUL_template.md as your agent's persona file at:
~/.openclaw/workspace/SOUL.md
This is a template. Open it and rewrite it to define your own agent's personality, name, and speaking style.
Your previous SOUL.md (if any) is backed up as SOUL.md.bak.YYYYMMDD_HHMMSS in the same directory. You can restore it at any time:
cp ~/.openclaw/workspace/SOUL.md.bak.YYYYMMDD_HHMMSS ~/.openclaw/workspace/SOUL.md
systemctl --user restart openclaw-gateway
⚠️ Runningopenclaw updateornpm update openclawwill overwrite the patched dist files.
After any OpenClaw update, simply run the script again:
sudo bash apply_patches.shAll patches include idempotency checks — already-applied patches are skipped automatically.
A simple proxy that sits between OpenClaw and Ollama, logging the full system prompt sent to your model. Useful for debugging persona issues.
node tools/intercept-proxy.js
# Then change OC's Ollama base URL to http://127.0.0.1:11435/v1 and restart OCTests whether your Ollama model is responding with the correct persona.
bash tools/test-oc-style.sh [model_name]
# Example:
bash tools/test-oc-style.sh qwen2.5:14bChecks:
- No generic assistant phrases ("Certainly!", "Great question!", etc.)
- No underlying model name leakage (Qwen, Llama, etc.)
- No OpenClaw internal strings
- Agent name from SOUL.md appears in the response
- Patches are applied to OpenClaw's dist files under
/usr/lib/node_modules/openclaw/dist/ - Each patched file is backed up as
filename.bakbefore modification - If a version mismatch is detected, the script warns but continues
- If any patch target pattern is not found, the script stops with an error
MIT