Coordination
Shared Memory
Distributed key-value and vector memory with four isolation scopes for cross-agent state sharing.
Distributed state that agents share, scoped to exactly the right audience.
Shared memory is not just a storage API. It is the distributed state fabric that lets agents coordinate without standing up Redis, manual namespacing, or pub/sub wiring first.
One agent can write workflow state, another can read it, and a third can react to changes. The scopes make that state visible to exactly the right audience.
# Agent A writes workflow context
await app.memory.set("ticket:T-123.sentiment", {"mood": "angry", "urgency": "high"})
# Agent B reads it later in the same workflow
sentiment = await app.memory.get("ticket:T-123.sentiment")
# Agent C reacts to changes automatically
@app.memory.on_change("ticket:*:sentiment")
async def on_ticket_sentiment(event):
await app.call("notifications.alert", key=event.key, change=event.data)
# Vector memory is available too for RAG and retrieval
await app.memory.set_vector("doc:chunk-1", embedding, metadata={"source": "contracts.pdf"})
hits = await app.memory.similarity_search(query_embedding, top_k=5)// Agent A writes workflow context
await ctx.memory.set('ticket:T-123.sentiment', { mood: 'angry', urgency: 'high' });
// Agent B reads it later in the same workflow
const sentiment = await ctx.memory.get('ticket:T-123.sentiment');
// Agent C reacts to changes automatically
agent.watchMemory('ticket:*:sentiment', async (event) => {
await agent.call('notifications.alert', { key: event.key, change: event.data });
});
// Vector memory is available too for RAG and retrieval
await ctx.memory.setVector('doc:chunk-1', embedding, { source: 'contracts.pdf' });
const hits = await ctx.memory.searchVector(queryEmbedding, { topK: 5 });What just happened
- One write became shared workflow context for multiple agents
- A watcher turned memory changes into reactive behavior without extra queue setup
- Vector memory remained available on the same interface for retrieval patterns
Example change event:
{
"key": "ticket:T-123.sentiment",
"scope": "workflow",
"scope_id": "wf-123",
"action": "set",
"data": { "mood": "angry", "urgency": "high" },
"previous_data": null
}