AAnvio
Reference ArchiveSource Docs

Architecture

Anvio is an extensible AI agent platform ([ADR-0038](adr/0038-extensible-agent-platform-positioning.md)). It runs workspace agents in a multi-turn tool loop. It also delegates work to sub-agents, to e

7 min read

This is a migrated reference document from the original Anvio source repo. Content is preserved as-is; canonical documentation lives in the sections above in the sidebar.

Original path: docs/02-architecture.md

Anvio is an extensible AI agent platform (ADR-0038). It runs workspace agents in a multi-turn tool loop. It also delegates work to sub-agents, to external A2A agents and to vendor agent CLIs, and connects all of them to models, tools (built-in and MCP), skills, memory and chat channels.

By default it is one process with file-based state. Heavier infrastructure is opt-in (ADR-0007).

This page describes the code as of 2026-10-25. Where a capability is partial, the gap is stated and linked to ROADMAP.md.

System map

Rendering diagram…

Dependency rule

apps → platform → packages → core
  • packages/core holds schemas (zod), ports and shared primitives. It has no internal dependencies.
  • packages/platform is the composition root. Apps never assemble subsystems themselves.
  • Domain logic lives in packages/*, never in NestJS controllers or CLI command handlers.

Packages by role

RolePackages
Foundationcore, workspace, storage, auth (optional, off by default), events, observability, db (Level 3+)
Agent runtimeagents (tool loop), runtimes (execution backends), models (provider routing), tools (built-in tool gateway), memory, execution (sandboxed code)
Agent managementplatform (delegation, gateway worker), a2a, acp, harness
Identity and learningsouls, soul-gate, personas, learning, skills, knowledge
Planning and automationgoals, automation, workflows, blueprints, kanban, batch, hooks
Connectivitychannels, integrations (MCP), voice, credentials
Not wiredtool-bus (see audit CQ-024)

How a request is executed

Rendering diagram…

Key properties, verified by the E2E suite in tests/integration/e2e/:

  • Turn ordering. Turns on one session are serialised. Turns across sessions are bounded by a semaphore.
  • Stopping a turn. A user stop or an idle model timeout aborts the in-flight call.
  • Tool failures stay inside the turn. Unknown tools, bad arguments and refused paths are reported to the model rather than ending the turn.
  • First-use MCP calls can require human approval. The run is checkpointed and resumes after the decision.
  • Run failures are visible. A failing run marks the session failed, publishes AGENT_RUN_FAILED and sends a notice to the user.
  • Crash recovery. After a crash, sessions left in calling_model are repaired to failed. The run itself is not resumed (ROADMAP T-011).

Agents, personas and souls

  • Agent: workspace/agents/<name>.md. Its frontmatter selects persona, skills, model, runtime and soul.
  • Persona: workspace/personas/<name>.md. Its body becomes the system prompt. The agent's own Markdown body is used as its description, not as the prompt (ROADMAP R-07). If no persona is set, the agent name is used and the persona file must exist.
  • Soul: workspace/souls/<slug>/SOUL.md. It holds long-lived identity, the reporting manager, trusted channels and approvers, and the evolution policy. Self-evolution is gated by evolution.allowAutoUpdate and by soul-gate policy (25, 42).

Managing other agents

MechanismWhat it doesWhere
Sub-agent delegationdelegate_task runs another workspace agent in its own session and returns its answer. mixture_of_agents fans out to up to 8 agents. Nesting depth is limited to 3 (ANVIO_MAX_DELEGATION_DEPTH)packages/platform/src/delegation-depth.ts, 40
A2A serverPublishes /.well-known/agent.json (also agent-card.json) and serves A2A JSON-RPC on /a2a. API-key/JWT auth is available but off by defaultpackages/a2a/src/server, 78
A2A clientThe a2a_delegate tool (disabled by default) sends tasks to remotes listed in a2a.remotes. Configured remote credentials are not yet sent (T-048)packages/a2a/src/client
Vendor runtimesAn agent can run on Claude Code, Cursor, Codex or Antigravity through their CLIs/SDKs with vendor OAuth, with per-agent fallback chainspackages/runtimes, ADR-0009
CoordinationKanban lanes, goals, batch jobs, DAG workflows, blueprints and cron automations dispatch agent runs26, 27, 28, 32, 45

Two authentication layers

Keep these apart:

  1. Model API keys (ANTHROPIC_API_KEY, OPENAI_API_KEY, …). They power the local runtime's direct SDK/HTTP calls.
  2. Runtime OAuth (anvio setup-token --claude|--cursor|--codex|--antigravity). It powers vendor-CLI runtimes and is stored encrypted under workspace/connections/.

Do not set ANTHROPIC_API_KEY alongside runtime.provider: claude-code: the key shadows OAuth and bills API credits (ADR-0009, ADR-0011).

Progressive tiers

LevelStorageEventsAuthRequires
1 (default)Filesystem (workspace/sessions/*.json, memory/)In-processOff; HTTP surfaces bind to 127.0.0.1Node 20+ only
2storage.provider: sqlite (state.db, FTS5 search)In-processOptional—
3+PostgreSQL (packages/db), Redis, NATS JetStreamNATSJWTdocker/docker-compose.dev.yml

Level 1 was verified under load on 2026-10-24 (post-refactoring/03). Levels 2 and 3+ were not load-tested. Code meant for Level 1 must not take a Level 3+ dependency.

Extension points

There is no plugin system (ROADMAP T-058). The supported ways to extend Anvio without changing code:

  • Skills. Install from a directory, git or a catalog URL; upgrade and remove (05, 37).
  • MCP servers. Configure in workspace/mcp/servers.yaml, or let an agent add them through mcp_manage (07).
  • Event hooks. script and webhook handlers (31).
  • Blueprints and workflows (34, 45).
  • Model endpoints. Any OpenAI-compatible endpoint, through provider: custom + baseUrl.

New channel adapters, runtimes, non-OpenAI-compatible providers or built-in tools require code changes.

Edit on GitHub

Last updated on

On this page