Skip to content

Commit 0b5763e

Browse files
committed
docs(agency): add Mental Model section with multi-brain architecture diagram
1 parent d066799 commit 0b5763e

1 file changed

Lines changed: 88 additions & 17 deletions

File tree

docs/orchestration/AGENCY_API.md

Lines changed: 88 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,76 @@ Zod output, RAG context injection (v1 placeholder), `listen()` for voice
3030
WebSocket transport, `connect()` for channel adapters, and real per-agent
3131
streaming events on the sequential strategy.
3232

33+
## Mental Model
34+
35+
Agency is the multi-brain primitive. Each `agent()` in the roster carries a full
36+
[GMI](/architecture/gmi) brain: cognition (PAD mood, HEXACO traits, eight cognitive
37+
mechanisms), memory (episodic, semantic, procedural, working), persona, and
38+
tools. The agency layer adds three things on top of those brains.
39+
40+
**1. Orchestration strategy declares how outputs flow between brains.**
41+
Sequential chains them, parallel fans them out and synthesises, debate has them
42+
argue and refine, hierarchical lets a coordinator dispatch, graph DAG declares
43+
explicit dependencies. The strategy is the data-flow shape. Picking the
44+
strategy picks how brain-to-brain context propagates; the work itself happens
45+
inside each brain.
46+
47+
**2. Shared coordination primitives connect the brains.** A shared memory store
48+
(`memory: { shared: true }`), an [`AgentCommunicationBus`](https://github.com/framersai/agentos/blob/master/src/agents/agency/AgentCommunicationBus.ts)
49+
for structured agent-to-agent messages, RAG with per-agent access controls, and
50+
runtime synthesis via [`EmergentAgentForge`](https://github.com/framersai/agentos/blob/master/src/cognition/emergent/EmergentAgentForge.ts)
51+
when the static roster runs out of specialists.
52+
53+
**3. A team-wide coordination shell wraps the whole agency.** HITL approval
54+
gates, guardrails, resource controls (token, cost, time, call caps), provenance
55+
and audit logging, structured Zod output. These apply uniformly to the team
56+
rather than per-agent.
57+
58+
```mermaid
59+
graph TB
60+
Input["Input"]
61+
subgraph Agency["Agency · coordination shell · HITL · guardrails · controls · provenance"]
62+
Strategy["Orchestration strategy<br/>sequential · parallel · debate<br/>review-loop · hierarchical · graph"]
63+
subgraph Brains["GMI brains"]
64+
direction LR
65+
A["GMI A<br/>cognition · memory<br/>persona · tools"]
66+
B["GMI B<br/>cognition · memory<br/>persona · tools"]
67+
C["GMI C<br/>cognition · memory<br/>persona · tools"]
68+
end
69+
SharedMem["Shared memory<br/>memory: shared: true"]
70+
Bus["AgentCommunicationBus"]
71+
Strategy -->|routes outputs| A
72+
Strategy -->|routes outputs| B
73+
Strategy -->|routes outputs| C
74+
A <--> SharedMem
75+
B <--> SharedMem
76+
C <--> SharedMem
77+
A <--> Bus
78+
B <--> Bus
79+
C <--> Bus
80+
end
81+
Input --> Strategy
82+
A --> Output["Coordinated output"]
83+
B --> Output
84+
C --> Output
85+
```
86+
87+
Three frames worth keeping:
88+
89+
- **Per-agent isolation still holds.** Each GMI has its own `brainId` and scopes
90+
its private memory by `thread | user | persona | organization`. The shared
91+
layer is additive. Leave it off (the default) and every brain stays isolated.
92+
- **Strategy is the flow, not the work.** Strategies define how state
93+
propagates between brains. The work happens inside each brain; the strategy
94+
decides who reads what and when.
95+
- **Flows compose.** `agency()` returns an `Agent`, so an entire agency can sit
96+
inside another agency, or as a step inside `workflow()`, or as a node inside
97+
`AgentGraph`. The brain abstraction stacks at every layer.
98+
99+
The `agency()` factory returns an `Agent`-compatible interface, so anywhere you
100+
called `agent().generate(input)` you can drop in `agency().generate(input)`. The
101+
team becomes a single composable unit.
102+
33103
## Scope: when to reach for `agency()`
34104

35105
`agency()` is for **single-request multi-agent coordination** — patterns where
@@ -59,23 +129,24 @@ own orchestrator and reach into agentos for the lower-level primitives
59129

60130
## Table of Contents
61131

62-
1. [Scope: when to reach for agency()](#scope-when-to-reach-for-agency)
63-
2. [API Hierarchy](#api-hierarchy)
64-
3. [Minimal Example](#minimal-example)
65-
4. [Orchestration Strategies](#orchestration-strategies)
66-
5. [Adaptive Mode](#adaptive-mode)
67-
6. [Emergent Agent Creation](#emergent-agent-creation)
68-
6. [Human-in-the-Loop (HITL)](#human-in-the-loop-hitl)
69-
7. [Memory and RAG](#memory-and-rag)
70-
8. [Voice and Channels](#voice-and-channels)
71-
9. [Guardrails and Security](#guardrails-and-security)
72-
10. [Permissions](#permissions)
73-
11. [Resource Controls](#resource-controls)
74-
12. [Observability and Callbacks](#observability-and-callbacks)
75-
13. [Structured Output with Zod](#structured-output-with-zod)
76-
14. [Nested Agencies](#nested-agencies)
77-
15. [Hierarchical Delegation — Manager Dispatches Dynamically](#hierarchical-delegation--manager-dispatches-dynamically)
78-
16. [Full-Featured Example](#full-featured-example)
132+
1. [Mental Model](#mental-model)
133+
2. [Scope: when to reach for agency()](#scope-when-to-reach-for-agency)
134+
3. [API Hierarchy](#api-hierarchy)
135+
4. [Minimal Example](#minimal-example)
136+
5. [Orchestration Strategies](#orchestration-strategies)
137+
6. [Adaptive Mode](#adaptive-mode)
138+
7. [Emergent Agent Creation](#emergent-agent-creation)
139+
8. [Human-in-the-Loop (HITL)](#human-in-the-loop-hitl)
140+
9. [Memory and RAG](#memory-and-rag)
141+
10. [Voice and Channels](#voice-and-channels)
142+
11. [Guardrails and Security](#guardrails-and-security)
143+
12. [Permissions](#permissions)
144+
13. [Resource Controls](#resource-controls)
145+
14. [Observability and Callbacks](#observability-and-callbacks)
146+
15. [Structured Output with Zod](#structured-output-with-zod)
147+
16. [Nested Agencies](#nested-agencies)
148+
17. [Hierarchical Delegation — Manager Dispatches Dynamically](#hierarchical-delegation--manager-dispatches-dynamically)
149+
18. [Full-Featured Example](#full-featured-example)
79150

80151
---
81152

0 commit comments

Comments
 (0)