Skip to content

About

Patches for OpenClaw to enable local LLM (Ollama) persona support with compact system prompts and Heartbeat memory logging

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

openclaw-ollama-patch

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


Prerequisites

  • OpenClaw installed via npm (sudo npm install -g openclaw)
  • Ollama installed and running with at least one model pulled
  • OpenClaw onboarding completed (openclaw onboard)

Installation

sudo bash apply_patches.sh

That's it. The script will:

  1. Check your OpenClaw version
  2. Find the correct dist files automatically
  3. Back up your existing SOUL.md (if any)
  4. Install the default persona template as SOUL.md
  5. Apply all patches
  6. Restart the OpenClaw gateway service

Customize Your Persona (SOUL.md)

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

Re-applying After an OpenClaw Update

⚠️ Running openclaw update or npm update openclaw will overwrite the patched dist files.

After any OpenClaw update, simply run the script again:

sudo bash apply_patches.sh

All patches include idempotency checks — already-applied patches are skipped automatically.


Tools

tools/intercept-proxy.js

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 OC

tools/test-oc-style.sh

Tests 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:14b

Checks:

  • 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

Notes

  • Patches are applied to OpenClaw's dist files under /usr/lib/node_modules/openclaw/dist/
  • Each patched file is backed up as filename.bak before 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

License

MIT

About

Patches for OpenClaw to enable local LLM (Ollama) persona support with compact system prompts and Heartbeat memory logging

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages