Roma Agent
Minimal, self-evolving autonomous agent framework in Rust.
中文文档 · Architecture · Quick Start · Highlights
Roma is a small, testable agent runtime. Every entry point — CLI, TUI, gateway, or a
workflow step — builds an AgentLoop and streams events out. Providers, tools, memory,
and skills sit behind traits, so tests swap in MockProvider / NullMemoryStore without
touching the loop. Workflow gates are the one thing kept outside the loop: they live in
the engine, where the model cannot reach them.
Roma — Greek muse of epic poetry and eloquence, chief of the Muses.
Highlights
- Multi-provider — OpenAI, Anthropic Claude, and Mock (testing), with
FailoverChain+CredentialPoolfor config-driven failover. - Layered memory — L0 (scratch) → L4 (identity), with background distillation off the critical path.
- Self-evolving skills — a discoverable
SKILL.mdindex, CRUD tools, auto-crystallization, and background quality review. - Engine-enforced workflows — YAML or runtime-built graphs with human-in-the-loop gates the model cannot skip (via gatedflow).
- Rich tools — file/code/ask builtins, MCP stdio tools merged at startup, and
web_fetch. - Messaging gateway — Telegram / WeChat (and extensible adapters) driving the same loop.
- SubAgents & scheduler — isolated-context delegation and autonomous periodic tasks (
--reflect).
Quick Start
This installs roma under ~/.cargo/bin (make sure it's on your PATH).
Requires a recent Rust stable toolchain (edition 2024; tested on 1.92+).
Build and check the workspace:
CLI
# Single-task mode (file in, file out, per-run artifacts)
# Artifacts land in /tmp/roma-task/runs/<run_id>/
# Gateway
# Configuration
Library
use AgentLoop;
use ;
use MockProvider;
use StreamExt;
async
Architecture
The diagram above shows the whole runtime; the subsystems below cover the parts that
aren't obvious from the picture. For the full reference, see
ARCHITECTURE.md · diagram sources in docs/archify/ ·
interactive overview.
Agent loop
One turn: inject context → stream the model → dispatch tools → continue or stop.
ToolHookcan veto a call;Denyreturnsis_errorto the model so the turn can recover, instead of aborting the run.- No tool call → the loop synthesizes
no_tool. Cancel ends the current turn and does not start another.
Layered memory
Layers are ordered by how long they should live. Consolidation is off the critical path:
the user gets LoopDone first; distillation runs afterward.
- L0 never persists · L1 auto-saves on exit · L3 is background-distilled · L4 is hand-curated and injected first.
- L2 is reserved (dashed in the diagram) — chunked summarization is not wired yet.
- Injection is budgeted (few L4/L3 files, short per file), so distillation has to stay selective.
Workflow gates
A gate is a real pause in gatedflow-core, not a line in the system prompt — that is
what makes it unskippable. The engine owns routing; the model only proposes steps.
- Static:
roma --workflow deploy.yaml. Dynamic:workflow_startat runtime; everyagentstep must declare a gate (Y rule). - Reject fails the workflow. Recovery means a new workflow, not letting the agent mutate the current one.
Gateway
Same level as REPL/TUI — platforms plug in via ChannelAdapter; the core loop is
unchanged. Telegram and WeChat ship today.
- One session lock per
platform:conversation_id. A new message gets a fresh cancel token and aborts whatever was still streaming. allowed_toolsandis_user_allowed()filter at the adapter before the handler runs.
Skills
SKILL.md on disk. Only a compact index goes into the system prompt; full text loads
on demand via skill_view, so the prompt stays small as skills accumulate.
- After a hard task the agent is nudged to crystallize the approach with
skill_manage; stale skills get patched in place. - A background review spot-checks quality and writes findings into L3.
Workspace Layout
| Crate | Description |
|---|---|
roma-core |
Core types, session, errors, agent events |
roma-provider |
Provider transport + OpenAI/Claude/Mock + FailoverChain + CredentialPool + SSE |
roma-tools |
Tool trait + builtin tools (file, code_run, ask_user, no_tool, …) |
roma-memory |
Layered memory system (L0–L4) |
roma-config |
config.toml + .env configuration model |
roma-agent |
AgentLoop, middleware, subagent, reflect scheduler, harness |
roma-skills |
Skill data model, filesystem store, conditional activation |
roma-workflow |
Adapter between AgentLoop and gatedflow-core |
roma-gateway |
Messaging gateway (Telegram, WeChat, …) |
roma-cli |
roma binary — TUI, workflow, task, gateway, setup |
roma-web |
WebFetchTool — HTTP fetch + HTML-to-Markdown |
roma-mcp |
MCP dynamic tool registration |
roma-bench |
Benchmarks |
roma-test-utils |
Shared test helpers |
Documentation
- Architecture reference — canonical, most detailed
- 中文文档 · 架构详解(中文)
- Diagram sources —
archifyspecs + interactive HTML
License
MIT — see the license field in Cargo.toml.