OnlyTerp/openclaw-optimization-guide

★ 387⑂ 0

Make your OpenClaw AI agent faster, smarter, and cheaper. Speed optimization, memory architecture, context management, model selection, and one-shot development guide.

About OnlyTerp/openclaw-optimization-guide

OnlyTerp/openclaw-optimization-guide is an open-source project on GitHub, mainly written in JavaScript. Make your OpenClaw AI agent faster, smarter, and cheaper. Speed optimization, memory architecture, context management, model selection It currently holds 387 stars and 0 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the AI Agent Memory board.

GitHub Repository Details

Repository OnlyTerp/openclaw-optimization-guide · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

OpenClaw Optimization Guide

Make your OpenClaw AI agent faster, smarter, cheaper, and actually safe to run in production.

Current sweep: July 2026 Stable baseline: 2026.6.11 33 parts Scorecard Awesome Benchmarks License: MIT PRs welcome

July 2026 sweep. Stable baseline: OpenClaw 2026.6.11 (released 2026-06-30). This refresh covers the 2026.6.8–2026.6.11 trains — automatic fast mode, working failover, per-agent cost visibility, prompt-cache retention, cron fallback controls, and channel-delivery self-recovery — and corrects the previous revision, which referenced a "2026.6.4" release and several config keys that were never shipped. See the correction note in Part 33.

By Terp — Terp AI Labs

---

Start With The July 2026 Reality Check

The June trains (2026.6.8 → 2026.6.11) were about making OpenClaw dependable. If you last read this guide in mid-June, these are the new rules:

1. Claude subscription-era advice is dead. Anthropic's April 4 policy change broke the old "Claude Pro/Max covers OpenClaw" path. Treat Claude as paid API / Bedrock / provider-routed usage unless your own install proves otherwise. 2. Cost visibility is per-agent now. openclaw gateway usage-cost --agent (or --all) shows spend per configured agent; cron it daily and treat spend jumps as context regressions. (There is no per-agent budget-cap config key — an earlier revision of this guide claimed one in error.) 3. Failover actually fires. Provider overloads are classified correctly, usage-limit responses route to fallbacks, and individual cron jobs can carry their own --fallbacks list (or run strict with --fallbacks ""). None of it helps without at least two configured lanes. 4. Fast mode is automatic. /fast auto (2026.6.10) runs short conversational turns in the provider's fast lane and returns to normal mode for longer work, with correct status through retries and fallback switches. 5. Long sessions got cheaper. Tool-heavy sessions now retain prompt-cache savings as results accumulate (2026.6.11) — one more reason to keep sessions long-lived and compaction healthy instead of resetting constantly. 6. Stuck channels self-recover. Telegram/WhatsApp queues that wedge after a crash or long-running task resume automatically in 2026.6.11. "Restart the gateway" should leave your runbooks.

Read Part 33 — June 2026 Field Guide first if you want the latest tricks before the deep dives.

The Harness Thesis

Most agent capability comes from the harness, not the weights.

The exact percentage is rhetoric. The operator lesson is concrete: model swaps help, but the big wins come from context budgets, memory discipline, tool permissions, flow control, provider routing, hooks, and verification loops.

flowchart LR
    subgraph Model["The Model (weights)"]
        M[Claude Opus 4.7
or your choice] end subgraph Harness["The Harness (operator-controlled) — this guide"] direction TB Inst[Instructions
SOUL/AGENTS/MEMORY/skills] Ctx[Context engineering
budgets + progressive disclosure] Tools[Tools + approvals
semantic categories] Guard[Guardrails
hooks, Task Brain, redaction] Mem[Memory layer
memory-core + LightRAG + dreaming] Orch[Orchestration
5 coordination patterns] end Model -.-> Harness Harness -.-> Results[Production results]

You usually cannot change the weights. You can change everything else: context, memory, tools, approvals, verification, cost controls, and orchestration. The rest of this guide is that operator-controlled layer.

Jump straight to the payoff

| Do this | For this outcome | |---|---| | Grade your setup → | 50-item Production Readiness Scorecard, score out of 100, shareable. | | Copy the reference config → | Working SOUL / AGENTS / MEMORY / TOOLS templates plus a conservative example config. | | See the numbers → | Reproducible benchmark methodology + harness + run template. | | Browse the ecosystem → | Curated list of skills, tools, papers, talks, adjacent projects. | | Hit a wall? → | Gotchas & FAQ, symptom-indexed. Most questions answered in one page. |

---

File Hierarchy At A Glance

OpenClaw's file layout maps 1:1 to Karpathy's three-tier LLM Wiki pattern published April 10, 2026. If you only remember one diagram from this guide, make it this one:

flowchart TB
    subgraph Raw["Raw sources — immutable, agent read-only"]
        Vault["vault/*"]
        Daily["memory/YYYY-MM-DD.md"]
    end
    subgraph Curated["Curated summaries — injected on every message"]
        Soul["SOUL.md
identity"] Agents["AGENTS.md
operational rules"] Mem["MEMORY.md
durable facts"] Dreams["DREAMS.md
reflection diary"] Skills["skills/*
on-demand playbooks"] end subgraph Artifacts["Generated artifacts — one-shot output"] PRs["PRs / commits"] Reports["Reports / transcripts"] end Raw -. memory_search .-> Agent((Agent)) Curated --> Agent Agent --> Artifacts Agent -. Deep-phase promote .-> Mem Artifacts -. auto-capture .-> Daily

| File | Purpose | Size cap | Written by | Read when | |------|---------|---------:|------------|-----------| | SOUL.md | Identity, invariants, non-negotiables | < 1 KB | Human | Every message | | AGENTS.md | Operational rules, decision trees, tool routing | < 2 KB | Human + agent (auditable) | Every message | | MEMORY.md | Durable facts promoted from short-term (pointer index) | < 3 KB | Agent via memory promote | Every message | | DREAMS.md | Human-readable reflection diary | latest N entries | Built-in Dreaming | Every message | | skills/ | Named playbooks | per-skill small | Human + SkillClaw | On activation | | vault/ | Raw source notes, transcripts, links | unbounded | Auto-capture + humans | On memory_search | | memory/YYYY-MM-DD.md | Daily short-term rollup | rolling | Auto-capture | On memory_search |

Full reasoning and update rules in Part 31 — The LLM Wiki Pattern In OpenClaw.

---

Who This Is For

---

Start Here (In This Order)

1. Part 25 — Architecture Overview — 15-minute primer on what OpenClaw actually is under the hood (gateway, Task Brain, memory layer, skills, surfaces). 2. Part 14 — Quick Checklist — 30-minute setup checklist covering the 80/20. 3. Part 17 — The One-Shot Prompt — copy-paste prompt that automates the whole setup. 4. Part 27 — Gotchas & FAQ — keep this open while you work. Half your questions are here.

---

What You Get (Numbers From Our Production Deployment)

| Metric | Before | After | Source | |--------|-------:|------:|--------| | Context file size (SOUL + AGENTS + MEMORY) | ~15 KB | ~5 KB | Part 1 | | Memory search latency | 2–5s (cloud) | <100ms (local) | Part 4, Part 10 | | Compaction crash rate | loops on 16K models | fixed in 4.15+ | Part 15 | | Coding-agent token usage | baseline | –60% | Part 19 — Repowise | | Sessions before audit trail | 0 surfaces | all surfaces | Part 24 — Task Brain |

Full numbers in benchmarks/.

---

Companion resources shipped with the guide

Alongside the 33 parts themselves, this repo now includes the tooling that turns "I read the guide" into "I can audit and reproduce the results":

---

What Changed In This Release (July 2026 Refresh)

Previous Late-May 2026 refresh

Earlier refreshes (Task Brain, ClawHub, the v4.0 architecture/migration/glossary primers, and the 2026.4.15 line) are captured in the version tables in Part 25 — Architecture Overview and Part 26 — Migration Guide.

---

How The Pieces Fit Together

flowchart LR
    You[You]
    subgraph Surfaces
        Canvas[Canvas UI]
        CLI[CLI / IDE]
        Cron[Cron / ACP]
    end
    subgraph Gateway["Gateway daemon (Task Brain)"]
        Ledger[Task ledger]
        Approvals[Semantic approvals]
        Auth[Auth / secrets]
    end
    subgraph Agents
        Main[Main agent]
        Workers[Sub-agents]
    end
    subgraph Memory["Memory layer"]
        MemCore[memory-core
MEMORY.md + DREAMS.md] Lance[memory-lancedb
vector search] Light[LightRAG
graph RAG] end subgraph Capabilities Hub[ClawHub skills] Hooks[Hooks] Tools[Tools] end

You --> Surfaces Surfaces --> Gateway Gateway --> Agents Agents --> Memory Agents --> Capabilities Capabilities -. register with .-> Gateway Memory -. feed .-> Agents

Full breakdown of each block in Part 25 — Architecture Overview.

---

Navigate By Goal

Not every part applies to every reader. Jump directly to the pillar that matches what you're trying to do:

| I want to… | Start with | |-------------|-----------| | Catch up on the latest changes | 33 June Field Guide · 26 Migration Guide · 27 Gotchas & FAQ | | Make my agent faster | 1 Speed · 2 Context Engineering · 3 Cron Bloat · 6 Models | | Stop it forgetting things | 4 Memory · 9 Vault · 10 Embeddings · 22 Built-In Dreaming · 31 LLM Wiki Pattern | | Reduce cost | 5 Orchestration · 6 Models · 8 One-Shotting · 22 Memory you can afford | | Handle real codebases | 18 LightRAG · 19 Repowise · 21 Real-time Sync | | Harden for production | 15 Infra Hardening · 23 ClawHub · 24 Task Brain · 29 Hook Catalog | | See what my agents are doing | 20 Observability · 24 Task Brain audit | | Automate self-improvement | 11 Auto-Capture Hook · 12 Self-Improving System · 13 Memory Bridge · 32 Self-evolving skills (SkillClaw) | | Run autonomous / overnight work | 5 Orchestration patterns · 30 Ralph Loop · 15 Worktrees · 26 Spec-Driven Development | | Enforce safety the agent can't ignore | 29 Hook Catalog · 24 Task Brain · 15 Infra Hardening | | Upgrade from an older version | 26 Migration Guide | | Look up a term you don't know | 28 Glossary | | Debug something weird | 27 Gotchas & FAQ |

---

Full Table of Contents

🎯 Primers & references

⚡ Speed & context 1. Speed — Stop Being Slow — trim context, add fallbacks, reasoning mode, localModelLean 2. Context Engineering — The Discipline — quadratic scaling, pruning, compaction, 5-min cache TTL trap 3. Cron Session Bloat — The Hidden Killer — session file accumulation, cleanup

🧠 Memory 4. Memory — Stop Forgetting Everything — 3-tier memory, Ollama, lancedb cloud storage, Copilot embeddings 9. Vault Memory System — folders, MOCs, claim-named notes, wiki-links 10. State-of-the-Art Embeddings — qwen3-embedding, GPU tier, Windows path, Copilot provider 11. Auto-Capture Hook — automatic knowledge extraction after every session 12. Self-Improving System — micro-learning loop, HOT/WARM/COLD tiers 13. Memory Bridge — give Codex / Claude Code access to your vault 22. Built-In Dreaming (memory-core) — official 3-phase consolidation, DREAMS.md, memory-you-can-afford (LightMem + vbfs) 31. The LLM Wiki Pattern In OpenClaw — Karpathy's three-tier pattern mapped onto SOUL/AGENTS/MEMORY/skills 33. June 2026 Field Guide — per-agent cost visibility, scheduled Policy attestations, working failover + cron fallbacks, memory promotion review, automatic fast mode

🤝 Orchestration & models 5. Orchestration — sub-agents-as-GC, Anthropic's 5 coordination patterns, CEO/COO/Worker, verification 6. Models — What To Actually Use — provider comparison, pricing, local, localModelLean 7. Web Search — Tavily, Brave, Serper, Gemini grounding 8. One-Shotting Big Tasks — research-first methodology 30. The Ralph Loop In OpenClaw — autonomous while true wrappers, PRD.json, overnight runs 32. Self-Evolving Skills With SkillClaw — skill population evolution, Mem²Evolve

🧩 Knowledge graph & codebase 18. LightRAG — Graph RAG — entities + relationships, Web UI, REST, LangFuse tracing 19. Repowise — Codebase Intelligence — 60% fewer tokens, 4x faster coding agents 21. Real-Time Knowledge Sync — event-driven file watcher, <6s vault → LightRAG sync

🔒 Hardening & security 15. Infrastructure Hardening — compaction crash loops, GPU contention, secrets, gateway crash-loop fix, reserve-token cap, auth hot-reload, approval redaction, parallel OpenClaw with git worktrees 23. ClawHub Skills Marketplace — marketplace, malware, install policy 24. Task Brain Control Plane — unified task ledger, semantic approvals, trust boundaries 29. The Hook Catalog — 8 copy-paste hooks, exit-code semantics, deterministic enforcement

🔭 Observability 20. Agent Observability — LangFuse, reranker, n8n, workflow automation

📖 Reference 25. Architecture Overview (v4.0+) — gateway / agents / memory / skills / surfaces primer 26. Migration Guide — opinionated upgrade paths with rollback 27. Common Gotchas & FAQ — symptom-indexed troubleshooting 28. Glossary & Terminology — every term this guide assumes, on one page

---

📊 Benchmarks — real numbers from a production system (context savings, search latency, reindex results, SWE-bench rankings)

📁 Example Vault — populated mini-vault showing MOCs, wiki-links, Agent Notes, and .learnings/ after 2 weeks of use

🤝 Contributing — how to propose corrections, new parts, and version-bump PRs

---

The Problem

If you're running a stock OpenClaw setup, you're probably dealing with:

What This Fixes

After this setup:

| Metric | Before | After | |--------|--------|-------| | Context per msg | 15-20 KB | 4-5 KB | | Time to respond | 4-8 sec | 1-2 sec | | Memory recall | Forgets daily | Remembers weeks | | Token cost/msg | ~5,000 tokens | ~1,500 tokens | | Long sessions | Degrades | Stable | | Concurrent tasks | One at a time | Multiple parallel |

How

GitHub Stars & Activity

387Stars
0Forks
0Open issues
JavaScriptLanguage

GitHub Popularity

GitHub stars387
Forks0
Open issues0
Primary languageJavaScript
License-
Stars gained today0
Created-
Last pushed-

Trending History

Trending statusnot on today's boards

Related AI Projects

1

pashpashpash / vault-ai

JavaScript★ 3,391⑂ 0
2

grpcer / ownmem

JavaScript★ 413⑂ 0
3

Goldentrii / AgentRecall-X

JavaScript★ 371⑂ 0
4

thedotmack / claude-mem

TypeScript★ 94,340⑂ 0
5

mem0ai / mem0

Python★ 65,719⑂ 0
6

volcengine / OpenViking

Python★ 38,212⑂ 0
7

topoteretes / cognee

Python★ 30,864⑂ 0
8

supermemoryai / supermemory

TypeScript★ 30,687⑂ 0

More AI Rankings