|
1 | 1 | # OpenClaw Optimization Guide |
2 | 2 |
|
3 | | -> **Tested on OpenClaw 2026.4.2 — April 3, 2026** · 21 parts · Battle-tested on a 14+ agent production deployment |
| 3 | +> **Tested on OpenClaw 2026.4.5 — April 7, 2026** · 22 parts · Battle-tested on a 14+ agent production deployment |
4 | 4 |
|
5 | 5 | ### Make Your OpenClaw AI Agent Faster, Smarter, and Actually Useful |
6 | 6 | #### Speed optimization, memory architecture, context management, model selection, graph RAG, codebase intelligence, and agent observability |
|
32 | 32 | 19. [Repowise — Codebase Intelligence](./part19-repowise-codebase-intelligence.md) - 60% fewer tokens, 4x faster coding agents. Dependency graphs, git analytics, dead code detection, architectural decisions. |
33 | 33 | 20. [Agent Observability](./part20-observability-and-services.md) - LangFuse for tracing all agent calls. n8n for workflow automation. Reranker for better search quality. |
34 | 34 | 21. [Real-Time Knowledge Sync](./part21-realtime-knowledge-sync.md) - Event-driven file watcher that syncs vault changes to LightRAG in under 6 seconds. No cron. Self-healing offline queue. The final piece that makes the knowledge graph always current. |
| 35 | +22. [Built-In Dreaming (memory-core)](#part-22-built-in-dreaming) - OpenClaw's official memory consolidation system. 3-phase sweep: Light, Deep, REM. Automatic promotion to MEMORY.md. The native replacement for our custom autoDream. |
35 | 36 |
|
36 | 37 | **📊 [Benchmarks](./benchmarks/)** — Real numbers from a production system (context savings, search latency, reindex results, SWE-bench rankings) |
37 | 38 |
|
@@ -1391,6 +1392,141 @@ Start with the basic vault system (Parts 4, 9). It works well up to ~500 files. |
1391 | 1392 |
|
1392 | 1393 | --- |
1393 | 1394 |
|
| 1395 | +## Part 22: Built-In Dreaming |
| 1396 | + |
| 1397 | +> **OpenClaw 2026.4+** — The official memory consolidation system built into memory-core. This is the native version of what our custom autoDream (Part 16) prototyped. |
| 1398 | +
|
| 1399 | +### What Changed |
| 1400 | + |
| 1401 | +Our [autoDream implementation (Part 16)](./part16-autodream-memory-consolidation.md) was a custom AGENTS.md-driven workaround we built by reverse-engineering Claude Code's memory consolidation pattern. It worked, but it required you to set up triggers, state tracking, and consolidation logic manually. |
| 1402 | + |
| 1403 | +OpenClaw 2026.4+ ships a **built-in dreaming system** inside memory-core that does all of this natively. If you're on 2026.4+, use the built-in version instead. |
| 1404 | + |
| 1405 | +### How It Works |
| 1406 | + |
| 1407 | +Dreaming runs a 3-phase sweep on a cron schedule (default: 3am daily): |
| 1408 | + |
| 1409 | +| Phase | What It Does | Writes to MEMORY.md? | |
| 1410 | +|-------|-------------|---------------------| |
| 1411 | +| **Light** | Sorts and stages recent short-term material. Dedupes daily signals. | No | |
| 1412 | +| **Deep** | Scores candidates and promotes durable entries to MEMORY.md using weighted ranking. | Yes | |
| 1413 | +| **REM** | Extracts themes and reflective patterns. Builds reflection summaries. | No | |
| 1414 | + |
| 1415 | +Plus a **Dream Diary** — a human-readable narrative entry in DREAMS.md written by a background subagent turn after each sweep. |
| 1416 | + |
| 1417 | +### Deep Ranking Signals |
| 1418 | + |
| 1419 | +Deep phase decides what becomes long-term memory using 6 weighted signals: |
| 1420 | + |
| 1421 | +| Signal | Weight | What It Measures | |
| 1422 | +|--------|--------|-----------------| |
| 1423 | +| Frequency | 0.24 | How many short-term signals the entry accumulated | |
| 1424 | +| Relevance | 0.30 | Average retrieval quality for the entry | |
| 1425 | +| Query diversity | 0.15 | Distinct query/day contexts that surfaced it | |
| 1426 | +| Recency | 0.15 | Time-decayed freshness score | |
| 1427 | +| Consolidation | 0.10 | Multi-day recurrence strength | |
| 1428 | +| Conceptual richness | 0.06 | Concept-tag density from snippet/path | |
| 1429 | + |
| 1430 | +Entries must pass `minScore`, `minRecallCount`, and `minUniqueQueries` thresholds to be promoted. |
| 1431 | + |
| 1432 | +### Quick Start |
| 1433 | + |
| 1434 | +```json |
| 1435 | +{ |
| 1436 | + "plugins": { |
| 1437 | + "entries": { |
| 1438 | + "memory-core": { |
| 1439 | + "config": { |
| 1440 | + "dreaming": { |
| 1441 | + "enabled": true |
| 1442 | + } |
| 1443 | + } |
| 1444 | + } |
| 1445 | + } |
| 1446 | + } |
| 1447 | +} |
| 1448 | +``` |
| 1449 | + |
| 1450 | +### Custom Cadence |
| 1451 | + |
| 1452 | +```json |
| 1453 | +{ |
| 1454 | + "plugins": { |
| 1455 | + "entries": { |
| 1456 | + "memory-core": { |
| 1457 | + "config": { |
| 1458 | + "dreaming": { |
| 1459 | + "enabled": true, |
| 1460 | + "timezone": "America/New_York", |
| 1461 | + "frequency": "0 */6 * * *" |
| 1462 | + } |
| 1463 | + } |
| 1464 | + } |
| 1465 | + } |
| 1466 | + } |
| 1467 | +} |
| 1468 | +``` |
| 1469 | + |
| 1470 | +### Slash Commands |
| 1471 | + |
| 1472 | +``` |
| 1473 | +/dreaming status — Check current state, last run, next scheduled run |
| 1474 | +/dreaming on — Enable dreaming |
| 1475 | +/dreaming off — Disable dreaming |
| 1476 | +/dreaming help — Show usage info |
| 1477 | +``` |
| 1478 | + |
| 1479 | +### CLI Commands |
| 1480 | + |
| 1481 | +```bash |
| 1482 | +# Preview what would be promoted (dry run) |
| 1483 | +openclaw memory promote |
| 1484 | + |
| 1485 | +# Apply promotions to MEMORY.md |
| 1486 | +openclaw memory promote --apply |
| 1487 | + |
| 1488 | +# Limit to top N candidates |
| 1489 | +openclaw memory promote --limit 5 |
| 1490 | + |
| 1491 | +# Explain why a specific candidate would/wouldn't promote |
| 1492 | +openclaw memory promote-explain "router vlan" |
| 1493 | + |
| 1494 | +# Preview REM reflections without writing |
| 1495 | +openclaw memory rem-harness |
| 1496 | + |
| 1497 | +# JSON output for scripting |
| 1498 | +openclaw memory promote --json |
| 1499 | +openclaw memory rem-harness --json |
| 1500 | +``` |
| 1501 | + |
| 1502 | +### What Gets Written |
| 1503 | + |
| 1504 | +| Location | Content | |
| 1505 | +|----------|---------| |
| 1506 | +| `memory/.dreams/` | Machine state — recall store, phase signals, ingestion checkpoints, locks | |
| 1507 | +| `DREAMS.md` | Human-readable Dream Diary entries + phase summaries | |
| 1508 | +| `memory/dreaming/<phase>/YYYY-MM-DD.md` | Optional phase reports | |
| 1509 | +| `MEMORY.md` | Long-term promoted entries (Deep phase only) | |
| 1510 | + |
| 1511 | +### Dreams UI |
| 1512 | + |
| 1513 | +The Gateway Dreams tab shows: |
| 1514 | +- Current enabled/disabled state |
| 1515 | +- Phase-level status and managed-sweep presence |
| 1516 | +- Short-term, long-term, and promoted-today counts |
| 1517 | +- Next scheduled run timing |
| 1518 | +- Expandable Dream Diary reader |
| 1519 | + |
| 1520 | +### Should You Use This or Part 16? |
| 1521 | + |
| 1522 | +**Use Part 22 (built-in dreaming)** if you're on OpenClaw 2026.4+. It's the official, supported implementation with proper scoring, phase management, and a UI. |
| 1523 | + |
| 1524 | +**Use Part 16 (custom autoDream)** only if you're on an older version or need custom consolidation logic that the built-in system doesn't support. |
| 1525 | + |
| 1526 | +*Source: [OpenClaw Dreaming Documentation](https://docs.openclaw.ai/concepts/dreaming)* |
| 1527 | + |
| 1528 | +--- |
| 1529 | + |
1394 | 1530 | ## About |
1395 | 1531 |
|
1396 | 1532 | *Built by [Terp - Terp AI Labs](https://x.com/OnlyTerp)* |
|
0 commit comments