Metis provides a native, production-ready recursive multi-agent system designed for complex, deep software engineering and multi-step reasoning workflows. Unlike simple agent wrappers, Metis multi-agent coordination operates natively within the core engine, providing recursive task delegation, role-based tool sandboxing, physical workspace isolation, deterministic lifecycle control, and cascading configuration inheritance.
Metis implements an L0 → L1 → L2 → L3 → L4 recursive delegation hierarchy:
graph TD
L0[Root Agent: Coordinator / User CLI] -->|spawn_agent| L1[L1: Planner]
L0 -->|spawn_agent| L1_2[L1: Implementer]
L1 -->|spawn_agent| L2[L2: Sub-Implementer]
L2 -->|spawn_agent| L3[L3: Code Reviewer]
L3 -->|spawn_agent| L4[L4: Test Verifier]
Each spawned agent process receives a structured runtime context:
rootRunId: Globally unique identifier across the entire invocation tree.parentId: Agent identifier of the direct parent.agentId: Unique identifier for the spawned child agent.depth: Integer representing recursion depth (0for root,1for L1, ...,5for L5).
Agents are defined as Markdown files with YAML frontmatter located in:
- Project-level:
.metis/agents/*.md(highest precedence, scoped to repository) - User-level:
~/.metis/agents/*.md(global across all projects) - Built-in: Stored in the Metis core runtime catalog.
---
name: backend-engineer
description: Expert in Node.js, TypeScript backend architecture and APIs
model: anthropic/claude-3-7-sonnet
thinking: high
tools:
- read
- write
- edit
- bash
- spawn_agent
env:
NODE_ENV: test
---
You are an expert backend engineer. When implementing APIs:
1. Write clean, modular TypeScript code.
2. Ensure strict type safety and error boundaries.
3. Validate inputs using standard schema libraries.| Field | Type | Description |
|---|---|---|
name |
string (required) |
Unique identifier for the agent (kebab-case recommended). |
description |
string (required) |
Short description of role and specialization. |
model |
string (optional) |
Model identifier to use (e.g. openai/gpt-4o, anthropic/claude-3-7-sonnet). |
thinking |
string (optional) |
Thinking level (off, minimal, low, medium, high, xhigh). |
tools |
string[] (optional) |
Tool allowlist. Only listed tools will be available. If omitted, defaults to parent toolset. |
env |
Record<string, string> (optional) |
Custom environment variables injected into the agent runtime. |
systemPrompt / Body |
string (optional) |
Role-specific prompt instructions (the Markdown body below frontmatter). |
Metis provides 5 pre-configured roles out of the box:
graph LR
Coordinator[Coordinator<br/>(L0 Orchestrator)] --> Planner[Planner<br/>(Architecture & Plan)]
Coordinator --> Implementer[Implementer<br/>(Code Implementation)]
Coordinator --> Reviewer[Reviewer<br/>(Diff & Quality Review)]
Coordinator --> Verifier[Verifier<br/>(Testing & Validation)]
coordinator: Orchestrates high-level workflow, decomposes complex user requirements, and delegates tasks to subagents. Retainsspawn_agent,agent_management, and inspection tools.planner: Researches the codebase, designs modular implementation plans, and outlines architecture changes without directly modifying files.implementer: Executes concrete coding changes, file creations, edits, and refactorings with write permissions.reviewer: Read-only agent that inspects diffs, verifies adherence to specifications, and flags potential security or regression risks.verifier: Runs test suites, typechecks, linters, and runtime validation scripts to confirm correctness.
Spawns a child agent to perform a specific delegated task.
{
"agent": "implementer",
"task": "Implement JWT authentication middleware in src/auth.ts",
"mode": "sync",
"worktree": "branch",
"context": "Previous discussion: using RS256 with rotation support"
}mode:"sync": Blocks parent until child completes and returns the final structured result."async": Runs child in the background; parent receives agent ID and monitors asynchronously.
worktree:"inherit": Runs in current directory."branch": Creates an isolated Git Worktree branch."temp": Copies codebase into an isolated temporary directory.
Lists active and past child agents, their statuses (running, completed, failed, cancelled), depth, and metrics.
Deterministically waits for one or more background (async) child agents to complete with timeout support.
Terminates a runaway child agent. If cascade: true (default), kills all descendant subprocesses within the process group (PGID).
Sends a guidance or interrupt message to a running child agent.
Metis guarantees deterministic inheritance across recursively spawned child processes:
graph TD
CLI[Root CLI Overrides<br/>--provider, --model, --base-url] --> Inherit[Child Subprocess Inheritance]
Inherit --> AgentDef[Agent Markdown Frontmatter Overrides]
- Agent Frontmatter Definition (Highest priority for role-specific tool restrictions or explicit model bindings)
- Parent Runtime Context (Transfers resolved Provider, Base URL, API Keys, OpenRouter Headers, explicit
--skill,--extension) - Global CLI / Config Defaults (Default fallback)
- When the parent uses
--base-url <url>or OpenRouter, child processes automatically inherit the base URL, attribution headers (HTTP-Referer,X-Title), and routing preferences.
Protects system resources against runaway recursion:
max_spawn_depth: Maximum recursion depth (default:5, configurable via--max-spawn-depth).max_children_per_agent: Maximum children a single agent can spawn (default:8).max_concurrent_agents: Concurrency pool cap (default:4, configurable via--max-concurrent).
When an agent attempts to spawn a duplicate or circular task (e.g. A → B → A with identical prompts), SpawnGuard intercepts the execution and raises a DUPLICATE_TASK_WARNING. The model must provide explicit rationale or pass force: true to bypass.
The engine registers process-level exit and signal handlers (SIGINT, SIGTERM, exit). If the root or intermediate process terminates, all child process trees (PGID) are immediately and cleanly terminated.
When multiple agents edit files concurrently, worktree: "auto" or worktree: "branch:<name>" creates a Git Worktree from a snapshot of the parent workspace, including its uncommitted and untracked files. This prevents file locks and merge corruption without hiding code the parent is actively editing. Successful isolated workspaces are retained so the parent can inspect and integrate child changes; failed, cancelled, and timed-out workspaces are cleaned up automatically. Retained workspaces are removed during process shutdown if the parent has not integrated them earlier.
Child processes automatically strip dangerous injection environment variables (LD_PRELOAD, DYLD_INSERT_LIBRARIES, etc.), while preserving authentication keys safely.
All JSONL logs and trace outputs automatically mask sensitive API keys and authorization tokens.