Patterns
Pattern: Shared State
Pattern: Shared State
Category: Memory Source: Internal usage (repo as shared state), FOR-0012 Status: Active
When to Use
When multiple agents need to read and write to a common data store so that one agent's outputs are visible to others. Essential in multi-agent systems where coordination happens through artifacts rather than direct communication.
How It Works
- A shared state store is established (file system, database, shared memory, artifact repository)
- Each agent has read and/or write access to relevant parts of the store
- Agents write their outputs to the store in agreed-upon formats and locations
- Other agents read from the store to get context, inputs, or status updates
- Conventions (naming, directory structure, file formats) ensure consistency
- Version control or conflict resolution prevents data loss from concurrent writes
Example
In the Talent Factory, the git repository is the shared state store. When the Role Factory creates a new role, it writes role.md and agent.md to a specific directory path. Quinn (QA) reads those files to validate them. Ivan (Infrastructure) set up the directory conventions that make the files findable. The org chart (company/org-chart.md) is shared state that multiple roles read and update.
Tradeoffs
| Pro | Con |
|---|---|
| Decouples agents — they communicate through artifacts, not direct calls | Requires strict conventions for file locations and formats |
| Enables asynchronous coordination | Concurrent writes can create conflicts |
| Full audit trail via version control | Agents must know where to look for relevant data |
| Any new agent can participate by following conventions | Shared state can grow unwieldy without maintenance |
Factory Usage
- Git repository: The entire factory uses the repo as shared state — role definitions, org chart, status, decisions, and production line specs are all shared artifacts.
- company/org-chart.md: Read by CEO, CTO, and others to understand current team composition.
- company/STATUS.md: Shared state for factory progress, read and updated by multiple roles.
- departments/{dept}/{role}/: Each role's directory is shared state containing its definition and artifacts.