tonitangpotato/rustclaw

Rust-native AI agent framework with cognitive memory (Engram), multi-agent orchestration, and security-first design. Single binary, <100ms startup, ~5ms memory recall.

5

stars

77

commits

Rust

primary language

Apr 28, 2026

updated

README

๐Ÿฆ€ RustClaw

Rust-native AI agent framework with cognitive memory, multi-agent orchestration, and security-first design.

Single binary. Zero IPC overhead. Native Engram memory.

Why RustClaw?

FeatureOpenClawIronClawRustClaw
LanguageTypeScriptRustRust
MemoryMCP/externalPostgreSQLengramai (native)
Multi-agentConfig-basedNot yetHierarchical orchestration + GID code intelligence
Binary size~200MB (Node)~15MB~35MB
Startup~2s~1s<100ms
Memory recall~200ms (MCP)N/A~5ms

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            RustClaw Agent            โ”‚
โ”‚                                      โ”‚
โ”‚  Workspace Files (SOUL.md, etc.)     โ”‚
โ”‚  โ†•                                   โ”‚
โ”‚  Hooks (6 lifecycle points)          โ”‚
โ”‚  โ†•                                   โ”‚
โ”‚  Agent Loop (LLM + Tools)            โ”‚
โ”‚  โ†•                                   โ”‚
โ”‚  Engram (native cognitive memory)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ†“          โ†“          โ†“
 Telegram    CLI       (future)

Quick Start

# Build
cargo build --release

# Copy and edit config
cp rustclaw.example.yaml rustclaw.yaml
# Edit rustclaw.yaml with your API key and bot token

# Create workspace files
echo "Be helpful." > SOUL.md

# Run
./target/release/rustclaw run

Workspace Files

RustClaw uses markdown files as its "operating system" โ€” compatible with OpenClaw:

FilePurpose
SOUL.mdAgent personality and values
AGENTS.mdWorkspace conventions
USER.mdInfo about the human
TOOLS.mdLocal tool notes
HEARTBEAT.mdPeriodic check tasks
MEMORY.mdLong-term memory
IDENTITY.mdName, emoji, vibe

Tools

Built-in tools available to the agent:

  • exec โ€” Execute shell commands
  • read_file โ€” Read file contents
  • write_file โ€” Write files (creates dirs)
  • edit_file โ€” Surgical text replacement
  • list_dir โ€” List directory contents
  • web_fetch โ€” Fetch URL content
  • web_search โ€” Brave search API
  • engram_recall / engram_store โ€” Cognitive memory recall and storage
  • gid_* โ€” 30 graph-indexed development tools (code intelligence, task tracking, impact analysis)

Hooks

6 lifecycle hook points (inspired by IronClaw):

enum HookPoint {
    BeforeInbound,    // Before processing user message
    BeforeToolCall,   // Before executing a tool
    BeforeOutbound,   // Before sending response
    OnSessionStart,   // New session created
    OnSessionEnd,     // Session ended
    TransformResponse // Transform final response
}

Auth Profile Rotation

Multi-token auth with automatic rotation and cooldown tracking (matches OpenClaw's design):

~/.rustclaw/auth-profiles.json    โ† credential store (never in rustclaw.yaml)
  • Multiple OAuth profiles per provider with priority ordering
  • Round-robin rotation โ€” sorted by lastUsed (oldest first)
  • Auto-failover on 429 (rate limit) and 529 (overloaded)
  • Exponential backoff cooldown โ€” 1min โ†’ 5min โ†’ 25min โ†’ 1h max
  • Automatic cooldown expiry โ€” error counts reset after cooldown passes
  • Usage stats persisted to disk after each request
{
  "version": 1,
  "profiles": {
    "anthropic:keychain": { "type": "oauth", "provider": "anthropic", "access": "keychain", "refresh": "keychain", "expires": 9999999999999 },
    "anthropic:default":  { "type": "token", "provider": "anthropic", "token": "sk-ant-..." },
    "anthropic:manual":   { "type": "token", "provider": "anthropic", "token": "sk-ant-..." }
  },
  "order": { "anthropic": ["anthropic:keychain", "anthropic:default", "anthropic:manual"] }
}

Special "access": "keychain" profile uses dynamic OAuth from macOS Keychain (auto-refresh).

Memory

Native engramai integration โ€” neuroscience-grounded cognitive memory:

  • ACT-R activation model (frequency ร— recency power law)
  • Hebbian learning (co-activation links)
  • Ebbinghaus forgetting curves
  • Hybrid Search โ€” 15% FTS + 60% embedding + 25% ACT-R
  • LLM Extraction โ€” Claude Haiku extracts key facts at store time
  • EmpathyBus โ€” drive alignment, behavior feedback, emotional trends
  • Cross-language alignment โ€” Chinese SOUL drives align with English content via embeddings
  • Auto-recall before each LLM call (~5ms)
  • Auto-store after each LLM response (with fact extraction)
  • Auto-consolidation every 6 hours
  • Self-reflection every 24 hours (prune, decay, soul/heartbeat suggestions)
  • Anomaly detection โ€” monitors engram storage health (BaselineTracker)

Embedding Pipeline

All embeddings use nomic-embed-text (768-dim) via local Ollama:

StageEmbedding UseCost
StoreContent โ†’ vector for future recallLocal, free
RecallQuery โ†’ vector โ†’ cosine similarityLocal, free
Drive AlignmentContent vector โ†” drive vectors โ†’ importance boostReuses store embedding, zero extra cost

Drive alignment is multilingual by design โ€” embeddings capture semantic meaning across languages. A Chinese SOUL drive ("ๅธฎpotatoๅฎž็Žฐ่ดขๅŠก่‡ช็”ฑ") naturally aligns with English content ("trading profit") because the embedding model maps related concepts to nearby vectors regardless of language.

Roadmap

  • Core agent loop with tool execution
  • Telegram channel (long polling)
  • Native Engram memory (full EmpathyBus integration)
  • 6-point hook system
  • Auth profile rotation (multi-token, cooldown tracking)
  • Cron system (standard cron expressions + timezone)
  • Multi-agent orchestration (orchestrator + specialist sub-agents)
  • Safety layer (prompt injection detection, sensitive leak check)
  • GID integration (30 tools โ€” code intelligence, task tracking, impact analysis)
  • EmpathyBus (drive alignment, behavior feedback, emotional trends, self-reflection)
  • Cross-language drive alignment (embedding-based)
  • Voice I/O โ€” whisper.cpp STT (local, ~3s for 40s audio) + edge-tts TTS (Telegram voice messages)
  • Config hot-reload (FSEvents file watcher)
  • Stream mode (Telegram typing effect with chunked responses)
  • Skill system (markdown-based workflow definitions, auto-loaded from skills/)
  • Per-chat voice mode toggle
  • SQLite session persistence
  • Reply-to-message context (quoted message parsing)
  • Web dashboard enhancements (orchestrator view, agent name)
  • Hot-reload orchestrator config
  • WASM tool sandbox

License

AGPL-3.0 โ€” Free for open source use.

For commercial/proprietary deployments, a separate commercial license is available. See LICENSE for details.

Contributors

tonitangpotato

77 commits

tonitangpotato/rustclaw

Rust-native AI agent framework with cognitive memory (Engram), multi-agent orchestration, and security-first design. Single binary, <100ms startup, ~5ms memory recall.

5

stars

77

commits

Rust

primary language

Apr 28, 2026

updated

README

๐Ÿฆ€ RustClaw

Rust-native AI agent framework with cognitive memory, multi-agent orchestration, and security-first design.

Single binary. Zero IPC overhead. Native Engram memory.

Why RustClaw?

FeatureOpenClawIronClawRustClaw
LanguageTypeScriptRustRust
MemoryMCP/externalPostgreSQLengramai (native)
Multi-agentConfig-basedNot yetHierarchical orchestration + GID code intelligence
Binary size~200MB (Node)~15MB~35MB
Startup~2s~1s<100ms
Memory recall~200ms (MCP)N/A~5ms

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            RustClaw Agent            โ”‚
โ”‚                                      โ”‚
โ”‚  Workspace Files (SOUL.md, etc.)     โ”‚
โ”‚  โ†•                                   โ”‚
โ”‚  Hooks (6 lifecycle points)          โ”‚
โ”‚  โ†•                                   โ”‚
โ”‚  Agent Loop (LLM + Tools)            โ”‚
โ”‚  โ†•                                   โ”‚
โ”‚  Engram (native cognitive memory)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ†“          โ†“          โ†“
 Telegram    CLI       (future)

Quick Start

# Build
cargo build --release

# Copy and edit config
cp rustclaw.example.yaml rustclaw.yaml
# Edit rustclaw.yaml with your API key and bot token

# Create workspace files
echo "Be helpful." > SOUL.md

# Run
./target/release/rustclaw run

Workspace Files

RustClaw uses markdown files as its "operating system" โ€” compatible with OpenClaw:

FilePurpose
SOUL.mdAgent personality and values
AGENTS.mdWorkspace conventions
USER.mdInfo about the human
TOOLS.mdLocal tool notes
HEARTBEAT.mdPeriodic check tasks
MEMORY.mdLong-term memory
IDENTITY.mdName, emoji, vibe

Tools

Built-in tools available to the agent:

  • exec โ€” Execute shell commands
  • read_file โ€” Read file contents
  • write_file โ€” Write files (creates dirs)
  • edit_file โ€” Surgical text replacement
  • list_dir โ€” List directory contents
  • web_fetch โ€” Fetch URL content
  • web_search โ€” Brave search API
  • engram_recall / engram_store โ€” Cognitive memory recall and storage
  • gid_* โ€” 30 graph-indexed development tools (code intelligence, task tracking, impact analysis)

Hooks

6 lifecycle hook points (inspired by IronClaw):

enum HookPoint {
    BeforeInbound,    // Before processing user message
    BeforeToolCall,   // Before executing a tool
    BeforeOutbound,   // Before sending response
    OnSessionStart,   // New session created
    OnSessionEnd,     // Session ended
    TransformResponse // Transform final response
}

Auth Profile Rotation

Multi-token auth with automatic rotation and cooldown tracking (matches OpenClaw's design):

~/.rustclaw/auth-profiles.json    โ† credential store (never in rustclaw.yaml)
  • Multiple OAuth profiles per provider with priority ordering
  • Round-robin rotation โ€” sorted by lastUsed (oldest first)
  • Auto-failover on 429 (rate limit) and 529 (overloaded)
  • Exponential backoff cooldown โ€” 1min โ†’ 5min โ†’ 25min โ†’ 1h max
  • Automatic cooldown expiry โ€” error counts reset after cooldown passes
  • Usage stats persisted to disk after each request
{
  "version": 1,
  "profiles": {
    "anthropic:keychain": { "type": "oauth", "provider": "anthropic", "access": "keychain", "refresh": "keychain", "expires": 9999999999999 },
    "anthropic:default":  { "type": "token", "provider": "anthropic", "token": "sk-ant-..." },
    "anthropic:manual":   { "type": "token", "provider": "anthropic", "token": "sk-ant-..." }
  },
  "order": { "anthropic": ["anthropic:keychain", "anthropic:default", "anthropic:manual"] }
}

Special "access": "keychain" profile uses dynamic OAuth from macOS Keychain (auto-refresh).

Memory

Native engramai integration โ€” neuroscience-grounded cognitive memory:

  • ACT-R activation model (frequency ร— recency power law)
  • Hebbian learning (co-activation links)
  • Ebbinghaus forgetting curves
  • Hybrid Search โ€” 15% FTS + 60% embedding + 25% ACT-R
  • LLM Extraction โ€” Claude Haiku extracts key facts at store time
  • EmpathyBus โ€” drive alignment, behavior feedback, emotional trends
  • Cross-language alignment โ€” Chinese SOUL drives align with English content via embeddings
  • Auto-recall before each LLM call (~5ms)
  • Auto-store after each LLM response (with fact extraction)
  • Auto-consolidation every 6 hours
  • Self-reflection every 24 hours (prune, decay, soul/heartbeat suggestions)
  • Anomaly detection โ€” monitors engram storage health (BaselineTracker)

Embedding Pipeline

All embeddings use nomic-embed-text (768-dim) via local Ollama:

StageEmbedding UseCost
StoreContent โ†’ vector for future recallLocal, free
RecallQuery โ†’ vector โ†’ cosine similarityLocal, free
Drive AlignmentContent vector โ†” drive vectors โ†’ importance boostReuses store embedding, zero extra cost

Drive alignment is multilingual by design โ€” embeddings capture semantic meaning across languages. A Chinese SOUL drive ("ๅธฎpotatoๅฎž็Žฐ่ดขๅŠก่‡ช็”ฑ") naturally aligns with English content ("trading profit") because the embedding model maps related concepts to nearby vectors regardless of language.

Roadmap

  • Core agent loop with tool execution
  • Telegram channel (long polling)
  • Native Engram memory (full EmpathyBus integration)
  • 6-point hook system
  • Auth profile rotation (multi-token, cooldown tracking)
  • Cron system (standard cron expressions + timezone)
  • Multi-agent orchestration (orchestrator + specialist sub-agents)
  • Safety layer (prompt injection detection, sensitive leak check)
  • GID integration (30 tools โ€” code intelligence, task tracking, impact analysis)
  • EmpathyBus (drive alignment, behavior feedback, emotional trends, self-reflection)
  • Cross-language drive alignment (embedding-based)
  • Voice I/O โ€” whisper.cpp STT (local, ~3s for 40s audio) + edge-tts TTS (Telegram voice messages)
  • Config hot-reload (FSEvents file watcher)
  • Stream mode (Telegram typing effect with chunked responses)
  • Skill system (markdown-based workflow definitions, auto-loaded from skills/)
  • Per-chat voice mode toggle
  • SQLite session persistence
  • Reply-to-message context (quoted message parsing)
  • Web dashboard enhancements (orchestrator view, agent name)
  • Hot-reload orchestrator config
  • WASM tool sandbox

License

AGPL-3.0 โ€” Free for open source use.

For commercial/proprietary deployments, a separate commercial license is available. See LICENSE for details.

Contributors

tonitangpotato

77 commits

Languages

Rust

65.2%

HTML

33.8%