SGA-MCTS Atoms
Distill past Inspector-approved sessions into reusable atomic experience.
When Inspector signs off on a session with a high enough score, the plugin extracts atomic units of experience (compact action/observation/outcome strings) and stores them in a local SQLite database. Captain queries the store via retrieve_atoms during plan decomposition for new tasks, biasing decomposition toward strategies that previously worked.
The atom store is intentionally local and dependency-free: no embeddings, no network, plain SQLite + bag-of-tokens scoring. Trades retrieval quality for predictability and zero cost — works fine on a Raspberry Pi.
Install
Via OpenClaw plugins CLI (recommended):
openclaw plugins install clawhub:openclaw-sga-mcts-atoms
Or via npm:
npm install -g @msbel/openclaw-sga-mcts-atoms
Add to OpenClaw config
Append to ~/.openclaw/openclaw.json:
{
"plugins": {
"entries": {
"sga-mcts-atoms": {
"enabled": true,
"config": {
"extractorPython": "python3",
"extractorScript": "~/.openclaw/sga_mcts/atom_extractor.py",
"retrieverScript": "~/.openclaw/sga_mcts/atom_retriever.py",
"dbPath": "~/.openclaw/sga_mcts/atoms.db",
"minSessionScore": 0.7,
"topK": 5
}
}
}
}
}
Restart the gateway: systemctl --user restart openclaw-gateway.
Hooks + Tools
| Surface | What |
|---|---|
Hook agent_end | Auto-extract atoms when Inspector score ≥ minSessionScore |
Tool retrieve_atoms(query, k) | Captain calls during plan decomposition |
Tool extract_atoms(session_id) | Manual extraction for back-fill |
Atom store schema
CREATE TABLE atoms (
id INTEGER PRIMARY KEY,
session TEXT NOT NULL,
text TEXT NOT NULL UNIQUE,
score REAL NOT NULL DEFAULT 0,
created TEXT NOT NULL DEFAULT (datetime('now'))
);
text carries a UNIQUE constraint, so duplicate atoms across sessions collapse naturally.
Performance
- Extraction: ~50ms per session on a Pi 5 (intent: cheap, run after every approved session)
- Retrieval: ~20ms for 1000 atoms with bag-of-tokens scoring
- Storage: ~200 bytes per atom; 10K atoms ≈ 2MB SQLite file
- No network I/O. No embeddings. No external services.
License
MIT. Source: https://github.com/msbel5/openclaw-sga-mcts-atoms