CrabPath
by @jonathangu
Memory graph engine with caller-provided embed and LLM callbacks; core is pure, with real-time correction flow and optional OpenAI integration.
clawhub install crabpathπ About This Skill
name: crabpath description: Memory graph engine with caller-provided embed and LLM callbacks; core is pure, with real-time correction flow and optional OpenAI integration. metadata: openclaw: emoji: "π¦" requires: python: ">=3.10"
CrabPath
Pure graph core: zero required deps and no network calls. Caller provides callbacks.
Design Tenets
state.json)Quick Start
from crabpath import split_workspace, HashEmbedder, VectorIndexgraph, texts = split_workspace("./workspace")
embedder = HashEmbedder()
index = VectorIndex()
for nid, content in texts.items():
index.upsert(nid, embedder.embed(content))
Embeddings and LLM callbacks
HashEmbedder (hash-v1, 1024-dim)embed_fn / embed_batch_fn (e.g., text-embedding-3-small)llm_fn using gpt-5-mini (example)Session Replay
replay_queries(graph, queries) can warm-start from historical turns.
CLI
--state is preferred:
crabpath query TEXT --state S [--top N] [--json]
crabpath query TEXT --state S --chat-id CID
crabpath doctor --state S
crabpath info --state S
crabpath init --workspace W --output O --embedder openai
crabpath query TEXT --state S --llm openai
crabpath inject --state S --type TEACHING [--type DIRECTIVE]
Real-time correction flow:
python3 query_brain.py --chat-id CHAT_ID
python3 learn_correction.py --chat-id CHAT_ID
Quick Reference
crabpath init/query/learn/inject/health/doctor/infoquery_brain.py --chat-id and learn_correction.py for real-time correction pipelinesquery_brain.py traversal limits: beam_width=8, max_hops=30, fire_threshold=0.01max_fired_nodes and max_context_chars (defaults None; query_brain.py defaults max_context_chars=20000)examples/correction_flow/, examples/cold_start/, examples/openai_embedder/API Reference
split_workspace
- load_state
- save_state
- ManagedState
- VectorIndex
traverse
- TraversalConfig
- TraversalConfig.beam_width, .max_hops, .fire_threshold, .max_fired_nodes, .max_context_chars, .reflex_threshold, .habitual_range, .inhibitory_threshold
- TraversalResult
- apply_outcome
inject_node
- inject_correction
- inject_batch
suggest_connections, apply_connections
- suggest_merges, apply_merge
- measure_health, autotune, replay_queries
HashEmbedder
- OpenAIEmbedder
- default_embed
- default_embed_batch
- openai_llm_fn
chat_completion
Node
- Edge
- Graph
- split_workspace
- generate_summariesCLI Commands
crabpath init --workspace W --output O [--sessions S] [--embedder openai]crabpath query TEXT --state S [--top N] [--json] [--chat-id CHAT_ID]crabpath learn --state S --outcome N --fired-ids a,b,c [--json]crabpath inject --state S --id NODE_ID --content TEXT [--type CORRECTION|TEACHING|DIRECTIVE] [--json] [--connect-min-sim 0.0]crabpath inject --state S --id NODE_ID --content TEXT --type TEACHINGcrabpath inject --state S --id NODE_ID --content TEXT --type DIRECTIVEcrabpath health --state Scrabpath doctor --state Scrabpath info --state Scrabpath replay --state S --sessions Scrabpath merge --state S [--llm openai]crabpath connect --state S [--llm openai]crabpath journal [--stats]query_brain.py --chat-id CHAT_IDlearn_correction.py --chat-id CHAT_IDTraversal defaults
beam_width=8max_hops=30fire_threshold=0.01reflex_threshold=0.6habitual_range=0.2-0.6inhibitory_threshold=-0.01max_fired_nodes (hard node-count cap, default None)max_context_chars (hard context cap, default None; query_brain.py default is 20000)Paper
https://jonathangu.com/crabpath/
π‘ Examples
from crabpath import split_workspace, HashEmbedder, VectorIndexgraph, texts = split_workspace("./workspace")
embedder = HashEmbedder()
index = VectorIndex()
for nid, content in texts.items():
index.upsert(nid, embedder.embed(content))