AgentOS markAgentOS

Multi-Agent Architecture

View .mdllms.txt

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.

Channels on the left feed a central hub, which routes to three agent cards, each with subagent cards beneath it

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.

PartWhat it decidesDetailed page
RoutingWhich agent answers an inbound messageagents.md#routing
Agent teamWhich agent may delegate to whichagents.md#agent-team-preset
Subagent lifecycleHow child sessions run, end and report back, and where you see themSessions and History, web-ui.md#session-tab
Session accessWhich sessions an agent's session tools reachsessions.md#session-access

Each picture is followed by the same content as a Mermaid diagram, which is the searchable text of the picture.

Routing

Multi-agent routing: channel entries feed the bindings resolution with its six tiers, which routes to the agents ops, support and main; each agent has sessions, one with two subagent child sessions; the session access policy sits under them inside the gateway

  • A channel entry (telegram, slack, discord, ...) has an agent_id, main unless 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), then peer_kind alone, guild_id, team_id, account, and channel alone. 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 skills allowlist (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 restart after changing them.

Commands and the full match table: agents.md#routing. Config keys: configuration.md#agent-routing-bindings. Channel setup: Channels.

Agent Team

Agent team: you talk to the coordinator, which spawns the researcher, the writer and the reviewer; artifacts and evidence return to the coordinator; specialists do not delegate to other agents; human approval comes before external actions

  • agentos agents team create writes 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 has allow_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_agents is what sessions_spawn enforces.

The preset, role contracts and delegation modes: agents.md#agent-team-preset.

Subagent Lifecycle and the Session Panel

Subagent lifecycle: a parent turn calls sessions_spawn, child sessions go from queued to running to done, failed or cancelled, and the completion wake returns to the parent; beside it the Session panel with Changes and five subagents, the gateway methods it reads, and the sidebar tree

  • A turn calls sessions_spawn once per child; the call returns at once. Each child is a session of its own.
  • A child is queued, running, then done, failed (also a timeout or an abandoned run) or cancelled. At most subagents.max_concurrent_children children of one parent run at a time (default 2); the rest stay queued in 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_yield waits 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 --delegation to 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) and sessions.children (the runs the session spawned, in spawn order). It stays live through sessions.changed: a child's event carries parent_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

Session access decision as six checks in order: a caller that is you (the gateway owner), policy at its defaults, the caller's own session, visibility (self, spawned by the caller, tree, agent, all), the pair policy, and allow_agents for spawn and send

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:

  1. 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.
  2. Default policy. With visibility = "all", agent_to_agent = true and no allow_pairs, nothing is restricted.
  3. Own session. The session the tool is called from is always reachable.
  4. visibility. self hides 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. tree stops there. agent adds the caller agent's other sessions. all goes on to the pair policy.
  5. Pair policy. Sessions of the same agent pass. agent_to_agent = false refuses every other pair; otherwise an empty allow_pairs allows all pairs, and a non-empty one must list [caller, target] (* matches any agent, and pairs are directional).
  6. allow_agents. A cross-agent sessions_spawn or sessions_send must also pass the caller agent's subagents.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 obeys allow_agents when 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: