Shared Memory and State
Agents that share context and knowledge — the difference between a team and a group of strangers.
What You'll Learn
- Why isolated agents produce inconsistent results
- Three models for shared state: context passing, shared memory, and vector stores
- How to design state schemas that scale
- Preventing state corruption in multi-agent systems
Agents Without Shared Memory Are Goldfish
Agent A researches a customer's history. Agent B handles the customer's complaint. But Agent B doesn't know what Agent A found. So it asks the customer to repeat everything. Sound familiar? It's the same frustration you feel when a company transfers your call and you have to start over.
Without shared memory, each agent operates in isolation. The system has knowledge, but no individual agent can access the full picture. Shared state fixes this.
Context Passing: The Relay Baton
The simplest approach: each agent receives the accumulated context from all previous agents in its prompt. Agent A's output becomes part of Agent B's input, which becomes part of Agent C's input.
Pros: Simple to implement. No external infrastructure. Every agent has full history.
Cons: Context windows fill up fast. By agent 5 or 6, you're running out of room for the actual task. Doesn't scale.
Shared Memory Store: The Team Database
All agents read from and write to a central store — a database, a key-value store, or even a structured document. Each agent queries only what it needs instead of carrying everything.
Pros: Scales to many agents. Each agent gets relevant context without bloat. Persists across sessions.
Cons: Requires infrastructure. Agents need to know what to query. Stale data is a risk if updates lag.
Vector Store: The Semantic Brain
Store agent outputs as embeddings in a vector database. When an agent needs context, it performs a semantic search — "find everything related to customer billing issues" — and gets the most relevant pieces, regardless of when or which agent produced them.
Pros: Handles massive amounts of context. Agents retrieve only what's relevant. Gets smarter as more data accumulates.
Cons: More complex to set up. Embedding quality matters. Results can be unpredictable.
This lesson is for Pro members
Unlock all 300+ lessons across 30 courses with Academy Pro. Founding members get 90% off — forever.
Already a member? Sign in to access your lessons.