Multi-Agent Architecture
How several agents share one gateway: which agent an inbound message reaches, how a team of agents hands work around, what happens to the subagents a turn spawns, and which sessions an agent's tools may reach. This page is the overview; each section links to the page that documents the commands and settings.

Illustration generated with an image model; the diagrams below are the reference.
Use this page when you run more than the built-in main agent: a second agent
bound to a channel, the team preset, or agents that spawn subagents. With one
agent and no bindings, every message goes to main and none of the policies
here restrict anything.
| Part | What it decides | Detailed page |
|---|---|---|
| Routing | Which agent answers an inbound message | agents.md#routing |
| Agent team | Which agent may delegate to which | agents.md#agent-team-preset |
| Subagent lifecycle | How child sessions run, end and report back, and where you see them | Sessions and History, web-ui.md#session-tab |
| Session access | Which sessions an agent's session tools reach | sessions.md#session-access |
Each picture is followed by the same content as a Mermaid diagram, which is the searchable text of the picture.
Routing

- A channel entry (
telegram,slack,discord, ...) has anagent_id,mainunless you set it.[[bindings]]send the messages they match to another agent. - When several bindings match, the most specific tier wins: exact peer
(
peer_kind+peer_id), thenpeer_kindalone,guild_id,team_id,account, andchannelalone. Inside a tier the rule listed first in the config wins. - No match falls back to the channel entry's
agent_id. So does a binding that names an unknown or disabled agent. - Each agent has its own workspace, model, tool policy and, optionally, a
skillsallowlist (agents.md#per-agent-skills). - The agent is part of the session key (
agent:ops:…), so a chat bound to another agent starts a new session. A subagent is a child session of the session that spawned it. - The CLI, the web console and the desktop app name the agent themselves
(
agentos agent --agent ops ...); bindings only route channel traffic. - Bindings are read when the gateway starts: run
agentos gateway restartafter changing them.
Commands and the full match table: agents.md#routing.
Config keys: configuration.md#agent-routing-bindings.
Channel setup: Channels.
Agent Team

agentos agents team createwrites four agents: a coordinator you talk to and a researcher, writer and reviewer it delegates to.- The only delegation edges are the coordinator's:
allow_agents = ["researcher", "writer", "reviewer"]. Each specialist hasallow_agents = []: it can still spawn helpers of its own kind, but no other agent. There is no edge between specialists and none back to the coordinator; results come back as the spawn's completion. - Specialists return artifacts and evidence to the coordinator, never act externally and do not contact you directly.
- All four role contracts start with the same rule: get human approval before any external send, publication, purchase, deletion or change to a production system.
delegation_mode = "prefer"is prompt guidance only.allow_agentsis whatsessions_spawnenforces.
The preset, role contracts and delegation modes:
agents.md#agent-team-preset.
Subagent Lifecycle and the Session Panel

- A turn calls
sessions_spawnonce per child; the call returns at once. Each child is a session of its own. - A child is
queued,running, thendone,failed(also a timeout or an abandoned run) orcancelled. At mostsubagents.max_concurrent_childrenchildren of one parent run at a time (default 2); the rest stayqueuedin spawn order. - When the children of a spawn group have ended, the parent session is woken once with their results. The wake turn runs under the authority ceiling of the turn that spawned the child, never more: a child a channel turn spawned does not wake its parent with your reach.
- A scheduled run is the exception: it is one-shot, so nothing under it is
ever woken. Its
sessions_yieldwaits for the children and returns their results in the same turn, and every subagent under the run does the same for its own children (a job needs--delegationto spawn at all); see Scheduling. - The Session panel of the web console and the desktop app reads
checkpoints.summary(lines added and removed since the session's first checkpoint),checkpoints.diff(the changed files' diff) andsessions.children(the runs the session spawned, in spawn order). It stays live throughsessions.changed: a child's event carriesparent_session_key, so the panel showing that parent refreshes. - Both sidebars list child sessions under the session that spawned them, with the same avatar as the panel. An avatar is drawn from the child's session key alone, so it is the same in every client.
Concurrency, restarts and wake delivery:
sessions.md#abort-a-running-turn.
The panel: web-ui.md#session-tab and
desktop-app.md#session. The sidebar tree:
web-ui.md#layout-and-routes and
desktop-app.md#subagents-under-their-session.
The methods:
http-api.md#session-children-and-workspace-changes.
Session Access Decision

One check covers sessions_send, sessions_list, sessions_history,
sessions_yield, session_pin, session_search, the acp tool and
session-bound cron jobs. In order:
- Your own caller. A turn from your CLI or web console is not
limited by
[session_access]. The caller is judged by the original requester, not by the envelope a queued turn runs in: a turn a channel or another agent queued on a console session is not yours. - Default policy. With
visibility = "all",agent_to_agent = trueand noallow_pairs, nothing is restricted. - Own session. The session the tool is called from is always reachable.
visibility.selfhides every other session (only a page of a spawned child's final answer stays readable). Otherwise a session the caller spawned, at any depth, is reachable, even on another agent.treestops there.agentadds the caller agent's other sessions.allgoes on to the pair policy.- Pair policy. Sessions of the same agent pass.
agent_to_agent = falserefuses every other pair; otherwise an emptyallow_pairsallows all pairs, and a non-empty one must list[caller, target](*matches any agent, and pairs are directional). allow_agents. A cross-agentsessions_spawnorsessions_sendmust also pass the caller agent'ssubagents.allow_agents, whatever let it through above. A spawn has no target session yet, so it starts at the pair policy; a spawn you start yourself skips the pair policy but still obeysallow_agentswhen it is set. When it is not set, the call is allowed unless a tool policy narrowed the caller.
A hidden session answers exactly like a missing one (Session not found),
and a refusal names the setting that refused it.
Every mode and its exceptions: sessions.md#session-access.
Config keys:
configuration.md#session-access-and-per-agent-skills.
About the Pictures
The four diagrams are drawn in the console's dark theme colours and typefaces,
and the agent and subagent avatars come from the product's own generator
(frontend/src/lib/subagent-avatar.ts). They have their own dark background
and a thin frame, so they read the same on a light and on a dark page. When a
picture and its Mermaid diagram disagree with the code, the code is right:
please report it.
Read next: