How chris-han/metaclaw works
1. Repository shape
- This is a multi-package monorepo centered on the Python metaclaw runtime, with a TypeScript OpenClaw plugin, an optional memory sidecar, a benchmark suite, and a large set of skill/memory assets used at runtime and for evaluation.
2. Main runtime entrypoint
- The primary application is the metaclaw Python package.
- Its top-level responsibilities are: CLI handling, configuration management, local proxy startup, agent auto-configuration, session/state tracking, and orchestration of the skills, memory, RL, and scheduler subsystems.
- Key entry modules include cli.py, launcher.py, api_server.py, setup_wizard.py, and scheduler.py.
3. Serving/data plane
- MetaClaw sits in front of a personal agent or client as a local proxy.
- Incoming chat requests flow from the agent into MetaClaw, where the request is enriched with skills and optionally memory, then forwarded to the configured upstream LLM provider.
- The proxy supports both OpenAI-compatible and Anthropic-compatible request shapes, which is why there are adapter and compatibility layers such as claw_adapter.py and weaver_compat.py.
4. Agent integration boundary
- The repo explicitly supports multiple “claws”/clients: OpenClaw, CoPaw, IronClaw, PicoClaw, ZeroClaw, NanoClaw, NemoClaw, Hermes, and a manual/none mode.
- MetaClaw’s startup path can rewrite or patch the target agent’s local config, then restart that agent so traffic routes through the MetaClaw proxy automatically.
- This is a clear boundary between MetaClaw-managed local configuration and the external personal agent runtime.
5. Skills subsystem
- Skills are short, local Markdown instructions stored under ~/.metaclaw/skills and seeded from memory_data/skills.
- At runtime, the system retrieves relevant skills and injects them into prompts.
- After sessions, the system can summarize new learning into new skill files, so the skill library evolves over time.
- The metaclaw/memory namespace also contains skill/promotion/policy logic, suggesting skill evolution is tightly coupled to memory and retrieval policy.
6. Long-term memory subsystem
- The memory layer stores cross-session facts such as preferences, project state, and episodic summaries.
- It supports retrieval modes like keyword/semantic/hybrid and has its own local storage and policy controls.
- Memory can run in-process or be delegated to the optional memory sidecar package under openclaw-metaclaw-memory/sidecar, which exposes a local HTTP service and isolates memory reads/writes from the main proxy.
7. RL / continual learning subsystem
- When RL is enabled, live conversation turns are turned into training samples, scored asynchronously by a PRM/judge model, and sent to a backend for LoRA-style fine-tuning.
- The backend is abstracted so the same control plane can target Tinker, MinT, or Weaver.
- The repo includes orchestration for batching, replay, failover, and hot-swapping updated weights back into service.
- There is also optional OPD (on-policy distillation), where a teacher model supplies log-probabilities through an OpenAI-compatible completions endpoint.
8. Scheduler and async execution
- The default “auto” mode adds a scheduler that defers weight updates to low-interruption windows such as sleep hours, idle periods, or Google Calendar meetings.
- This makes the serving path and training path intentionally decoupled: users keep chatting while scoring, consolidation, and optimization run in the background.
- The scheduler is therefore a key architectural boundary between interactive serving and non-interactive learning.
9. Configuration, auth, and state
- Local state is persisted under ~/.metaclaw, with configuration managed through config.py, config_store.py, auth_store.py, cli_session_store.py, and runtime_state.py.
- The setup wizard initializes the system, while the CLI provides lifecycle commands for start/stop/status/config/auth/uninstall.
- These stores define the persistent control plane for both runtime behavior and external provider credentials.
10. External dependencies and service boundaries
- The main external systems are LLM APIs, RL training backends, optional calendar access, and optional agent runtimes.
- The repo also supports optional compatibility packages for alternate backends and agent ecosystems, keeping those dependencies out of the core package.
- This makes the core MetaClaw process portable while allowing specialized integrations to be added only when needed.
11. Benchmarking and evaluation
- The benchmark/ package is a separate evaluation stack with its own CLI, validators, inference/scoring/reporting commands, configs, and datasets.
- It uses packaged daily workspace snapshots, session logs, and question sets to evaluate learning/adaptation over time.
- This is structurally independent from the runtime proxy, but it exercises the same skill/memory/agent assumptions.
12. Extension and packaging layer
- openclaw-metaclaw-memory is a distributable plugin package with a compiled TypeScript client plus a Python sidecar implementation.
- extensions/metaclaw-openclaw is the lightweight OpenClaw integration package.
- Together they show that MetaClaw is designed as a core Python control plane with pluggable client-side integrations and optional isolated services.
13. Supporting assets, scripts, and tests
- scripts/ contains experiment runners, ablations, benchmark helpers, and end-to-end test orchestration.
- tests/ covers CLI behavior, launcher behavior, memory, scheduler, rollout, and utility functions.
- The large memory_data/ tree acts as bundled seed content: skills plus policy/data used to bootstrap the system.
14. High-level architectural flow
- User chats with a supported agent.
- The agent routes requests through MetaClaw’s local proxy.
- The proxy injects skills and optionally long-term memory.
- Responses are returned immediately.
- In parallel, conversation data is summarized, stored, scored, and optionally used for RL training and skill evolution.
- Scheduler and backend abstractions decide when learning updates are safe to apply.
Main entry points: manager.py Memory manager · api_server.py API server · run_cmd.py Run pipeline · launcher.py Launcher
Components 28
Core runtime
Python MetaClaw control plane and serving path
- CLI · User-facing command surface for lifecycle, auth, config, and status
metaclaw/cli.py - Launcher · Starts the local proxy and wires startup modes
metaclaw/launcher.py - API server · Serves incoming agent traffic and forwards requests upstream
metaclaw/api_server.py - Setup wizard · Bootstraps local configuration and agent auto-setup
metaclaw/setup_wizard.py - Config store · Persists local configuration and runtime settings
metaclaw/config_store.py - Auth store · Persists provider credentials and auth material
metaclaw/auth_store.py - Runtime state · Tracks active sessions and control-plane runtime state
metaclaw/runtime_state.py - Scheduler · Defers updates and learning work to low-interruption windows
metaclaw/scheduler.py - Claw adapter · Normalizes request shapes for compatible agent/provider flows
metaclaw/claw_adapter.py - Weaver compat · Compatibility layer for alternate provider or request conventions
metaclaw/weaver_compat.py
Memory system
In-process memory, skills, and optional sidecar
- Skill manager · Loads, injects, and evolves Markdown skills at runtime
metaclaw/skill_manager.py - Memory manager · Coordinates retrieval, storage, consolidation, and policy
metaclaw/memory/manager.py - Memory store · Local persistence for cross-session facts and episodic summaries
metaclaw/memory/store.py - Memory policy · Controls recall, promotion, and scope behavior
metaclaw/memory/policy.py - Sidecar service · Optional isolated HTTP memory service for reads and writes
openclaw-metaclaw-memory/sidecar/metaclaw_memory_sidecar/server.py
Learning loop
RL, rollout, scoring, and backend orchestration
- Trainer · Packages samples and coordinates backend fine-tuning
metaclaw/trainer.py - PRM scorer · Asynchronously scores turns before training or consolidation
metaclaw/prm_scorer.py - SDK backend · Abstracts training backends such as Tinker, MinT, and Weaver
metaclaw/sdk_backend.py - Rollout · Converts live conversations into training and replay artifacts
metaclaw/rollout.py - Env rollout · Runs rollout against OpenClaw-style agent environments
metaclaw/openclaw_env_rollout.py
Client integration
OpenClaw plugin and external agent boundary
- OpenClaw plugin · Client-side plugin package that connects OpenClaw to MetaClaw memory
openclaw-metaclaw-memory/src/index.ts - OpenClaw ext · Lightweight OpenClaw integration package
extensions/metaclaw-openclaw/index.ts
Benchmarking
Separate evaluation and reporting stack
- Benchmark CLI · Entry point for benchmark execution, inference, scoring, and reporting
benchmark/src/cli.py - Checks · Integrity and structure validators for benchmark data
benchmark/src/check/base.py - Run pipeline · Benchmark run, infer, scoring, and report stages
benchmark/src/run/run_cmd.py - Bench data · Packaged tasks, sessions, and workspace snapshots for evaluation
benchmark/data/metaclaw-bench
Seed assets
Bundled skill and policy data used at runtime and evaluation
- Skill seeds · Bundled skill markdown used to seed the runtime skill library
memory_data/skills - Policy seed · Bundled policy data used to bootstrap memory behavior
memory_data/store/policy.json
Connections 30
- CLI → Launcher: starts · CLI drives local runtime startup
- CLI → Setup wizard: initializes · CLI can bootstrap configuration and agent setup
- Launcher → API server: serves · Launcher brings up the local proxy/server
- Launcher → Scheduler: enables · Auto mode wires background scheduling
- API server → Claw adapter: normalizes · Proxy adapts inbound agent requests
- API server → Weaver compat: compatibility · Proxy supports alternate request/provider compatibility
- API server → Skill manager: injects · Serving path enriches prompts with skills
- API server → Memory manager: recalls · Serving path can attach long-term memory
- Memory manager → Memory store: persists · Memory writes and retrieval state are stored locally
- Memory manager → Memory policy: governs · Policy controls recall and promotion decisions
- Memory manager → Sidecar service: delegates · Optional sidecar can isolate memory operations
- Skill manager → Skill seeds: seeds · Runtime skill library is bootstrapped from bundled assets
- Skill manager → Memory manager: learns from · Post-session summaries can promote new skills
- Scheduler → Trainer: triggers · Scheduler decides when consolidation and updates run
- Trainer → PRM scorer: scores · Training pipeline uses asynchronous judge scoring
- Trainer → SDK backend: targets · Backend abstraction routes to supported training services
- Rollout → Trainer: feeds · Conversation rollouts become training samples
- Rollout → Memory manager: captures · Rollout captures memory-relevant conversation artifacts
- Env rollout → Rollout: specializes · Environment rollout is a concrete rollout mode
- OpenClaw ext → OpenClaw plugin: packages · Repository includes a lightweight OpenClaw integration package
- OpenClaw plugin → API server: routes to · Client plugin sends traffic through MetaClaw
- Benchmark CLI → Checks: validates · Benchmark stack checks data integrity and structure
- Benchmark CLI → Run pipeline: orchestrates · CLI drives benchmark run and scoring stages
- Run pipeline → Bench data: uses · Evaluation pipeline consumes packaged datasets and sessions
- Run pipeline → Memory manager: exercises · Benchmarks stress the same memory assumptions as runtime
- Run pipeline → Skill manager: exercises · Benchmarks also evaluate skill retrieval and injection behavior
- Policy seed → Memory manager: bootstraps · Seed policy informs local memory behavior at startup
- Config store → Launcher: configures · Launcher reads persisted runtime configuration
- Auth store → API server: authenticates · Provider credentials are consumed by the serving path
- Runtime state → Scheduler: tracks · State store supports scheduling and session coordination