Tools
OME
Every AI agent session starts fresh. Previous context is lost after resets, and users must repeat themselves. OME solves this by providing a zero-dependency persistent memory layer as an OpenClaw plugin, enabling agents to remember, learn, and continue across sessions.
Configuration Example
{
"plugins": {
"entries": {
"ome": {
"enabled": true,
"config": {
"dbPath": "~/.openclaw/ome/ome.db",
"maxPrependChars": 4000,
"maxMsgChars": 500,
"maxRecentMsgs": 3,
"maxRecentTools": 5,
"logLevel": "info"
}
}
}
}
}
README
# OME โ OpenClaw Memory Engine
[ไธญๆๆๆกฃ](README_CN.md)
**Persistent Memory Plugin for AI Agents**
[](LICENSE)
[](https://nodejs.org/)
Every AI agent session starts fresh. Previous context is lost after resets, and users must repeat themselves. OME solves this by providing a zero-dependency persistent memory layer as an OpenClaw plugin, enabling agents to remember, learn, and continue across sessions.
## Features
- **Cross-Session Persistence** โ Survive `/new` resets with automatic checkpoint saving
- **Dual-Track Checkpoints** โ Mechanical snapshots (always available) + LLM summaries (when available)
- **Per-Agent Isolation** โ Each agent maintains its own private memory space
- **5-Level Memory Hierarchy** โ D0 (themes) โ D1 (gist) โ D2 (outline) โ D5 (exchanges) โ D6 (raw)
- **4-Level Scope System** โ Global, task, agent, and session scopes
- **Automatic Context Injection** โ Previous session context restored on new sessions
- **Zero Dependencies** โ Uses only Node.js 24+ built-in modules (`node:sqlite`)
- **SQLite WAL Storage** โ Concurrent-safe, 1-5ms write latency
- **Configurable** โ All parameters user-overridable, no hardcoded values
## Requirements
- Node.js >= 24.0.0 (uses built-in `node:sqlite`)
- OpenClaw >= 2026.2.0 (peer dependency)
## Installation
### Option 1: Copy to Extensions
```bash
# Create the extension directory
mkdir -p ~/.openclaw/extensions/ome
# Copy plugin source and config
cp -r src/ ~/.openclaw/extensions/ome/src/
cp -r config/ ~/.openclaw/extensions/ome/config/
# Enable the plugin in openclaw.json
cat <<'EOF' >> ~/.openclaw/openclaw.json
{
"plugins": {
"entries": {
"ome": {
"enabled": true
}
}
}
}
EOF
```
### Option 2: Git Clone
```bash
# Clone the repository
git clone https://github.com/user/ome.git ~/.openclaw/extensions/ome
# Or symlink from your dev directory
ln -s /path/to/ome ~/.openclaw/extensions/ome
```
After either approach, restart the OpenClaw Gateway.
## Configuration
OME uses a layered configuration system. Default values are built-in and can be overridden via `~/.openclaw/openclaw.json`:
```json
{
"plugins": {
"entries": {
"ome": {
"enabled": true,
"config": {
"dbPath": "~/.openclaw/ome/ome.db",
"maxPrependChars": 4000,
"maxMsgChars": 500,
"maxRecentMsgs": 3,
"maxRecentTools": 5,
"logLevel": "info"
}
}
}
}
}
```
| Parameter | Default | Description |
|-----------|---------|-------------|
| `dbPath` | `~/.openclaw/ome/ome.db` | Path to the SQLite database file |
| `maxPrependChars` | `4000` | Character budget for injected context |
| `maxMsgChars` | `500` | Max characters per message in checkpoints |
| `maxRecentMsgs` | `3` | Number of recent conversation turns to keep |
| `maxRecentTools` | `5` | Number of recent tool calls to keep |
| `maxModifiedFiles` | `20` | Number of modified files tracked |
| `logLevel` | `"info"` | Log verbosity: `debug`, `info`, `warn`, `error` |
## Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ OpenClaw Gateway โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโ
โ โ โ
โโโโโโดโโโโ โโโโโโดโโโโ โโโโโโดโโโโ
โ Main โ โAgent-A โ โAgent-B โ
โโโโโโฌโโโโ โโโโโโฌโโโโ โโโโโโฌโโโโ
โ โ โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโดโโโโโโโโโโโ
โ OME Engine โ
โโโโโโโโโโโโโโโโโโโโโโโค
โ before_agent_start โ โ Inject context
โ agent_end โ โ Save checkpoint
โ after_tool_call โ โ Track tool calls
โ before_reset โ โ Pre-reset save
โ gateway_stop โ โ Flush & close
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โโโโโโโโโโโโดโโโโโโโโโโโ
โ SQLite (WAL) โ
โ ~/.openclaw/ome/ โ
โโโโโโโโโโโโโโโโโโโโโโโ
```
Each agent connects to the shared OME Engine, which persists all memory and checkpoints into a single SQLite database using WAL mode for concurrent safety.
## How It Works
### Checkpoint Lifecycle
| Hook | Trigger | Action |
|------|---------|--------|
| `before_agent_start` | New session detected | Inject previous session context via `prependContext` |
| `agent_end` | Each agent run completes | Save dual-track checkpoint + write D6 raw memory |
| `after_tool_call` | File-modifying tool calls | Track tool calls; checkpoint on file modifications |
| `before_reset` | `/new` or session reset | Save final checkpoint + write D5 session summary |
| `gateway_stop` | Gateway shutdown | Flush all active agent states, close database |
### Memory Layers
| Layer | Content | Size | Retention |
|-------|---------|------|-----------|
| D0 | Theme tags | ~50 tokens | Permanent |
| D1 | One-line gist | ~200 tokens | Permanent |
| D2 | Structured outline | ~500 tokens | Permanent |
| D5 | Exchange summary | ~3000 tokens | 7 days |
| D6 | Raw transcript | Unlimited | 7 days |
Consolidation path: `D6 โ D5 โ D2 โ D1 โ D0` (asynchronous, handled by the Consolidator in Phase 3).
### Scope Hierarchy
```
/global โ Shared across all agents (user preferences, common knowledge)
/task/{task_id} โ Shared within a collaboration task (goals, progress, findings)
/agent/{agent_id} โ Private to a single agent
/session/{agent_id}/{sid} โ Temporary, scoped to one session
```
Visibility: An agent sees `/global` + its participating `/task` scopes + its own `/agent` scope + the current `/session`.
### Context Injection Format
When a new session starts, OME injects the following via `prependContext`:
```
[OME Memory Restored โ Last active: 15 minutes ago]
Goal: <current_goal>
Progress: <progress_summary>
Next step: <immediate_next>
Key findings: <key_findings>
Last user message: "<last_user_message>"
Recent conversation:
User: ...
Assistant: ...
Recent tool calls:
- edit({"filePath": "..."}) โ Success
Modified files: src/index.js, src/config.js
```
If an LLM summary exists, it is used first. Otherwise, OME falls back to the mechanical checkpoint (recent messages, tool calls, modified files).
## Project Structure
```
ome/
โโโ config/
โ โโโ openclaw.plugin.json # Plugin manifest and config schema
โโโ docs/
โ โโโ ARCHITECTURE.md # Detailed architecture documentation
โ โโโ DEPLOY.md # Deployment guide
โ โโโ DESIGN.md # Full design specification
โโโ src/
โ โโโ index.js # Plugin entry point and hook registration
โ โโโ config.js # Configuration defaults and merge logic
โ โโโ db.js # SQLite database module (schema, CRUD)
โ โโโ hooks/
โ โ โโโ before-agent-start.js # Context injection on new sessions
โ โ โโโ agent-end.js # Checkpoint + D6 memory on agent completion
โ โ โโโ after-tool-call.js # Tool call tracking + file-modify checkpoints
โ โ โโโ before-reset.js # Final checkpoint + D5 summary before reset
โ โ โโโ gateway-stop.js # Graceful shutdown and database close
โ โโโ services/
โ โ โโโ agent-state-service.js # In-memory agent state management
โ โ โโโ checkpoint-service.js # Dual-track checkpoint builder
โ โ โโโ context-service.js # prependContext builder
โ โโโ utils/
โ โโโ agent-resolver.js # Agent ID resolution strategies
โ โโโ logger.js # Configurable log wrapper
โ โโโ message-utils.js # Message parsing and text extraction
โโโ tests/
โโโ unit.test.js # Unit tests (Node.js built-in test runner)
```
## Testing
```bash
npm test
# or
node --test tests/unit.test.js
```
Tests use the Node.js built-in test runner (`node:test`) with zero external test dependencies.
## Roadmap
- **Phase 1**: Cross-session memory persistence โ **Complete**
- **Phase 2**: Multi-agent shared memory (Task Memory + Memory Bus) โ Designed
- **Phase 3**: Memory consolidation + daily reports โ Planned
## References & Acknowledgments
This project's design was informed by research and ideas from:
- [Letta](https://github.com/letta-ai/letta) โ Shared memory blocks, owner model, append-only patterns
- [CrewAI](https://github.com/crewAIInc/crewAI) โ Scope hierarchy tree design
- [LangGraph](https://github.com/langchain-ai/langgraph) โ Checkpointer vs Store dual-layer architecture
- CaveAgent (arXiv:2601.01569) โ State externalization for persistent agents
- SPL (arXiv:2602.21257) โ Token budget management strategies
## Disclaimer
This project is provided as-is, with no guarantees of continued maintenance, updates, or support. Use at your own discretion.
## License
MIT License. See [LICENSE](LICENSE) for details.
tools
Comments
Sign in to leave a comment