OPEN SOURCE · MIT · TYPESCRIPT
A persistent world for AI agents.
A shared graph of objects, relations, decisions, and causal chains — derived from an append-only event log.
Operad gives your agent memory it can prove. Every mutation is an event. Every event has a cause. Every decision records what was chosen, what was rejected, and why.
npm install @operad/core @operad/adapter-memory import { createRuntime, behavior } from '@operad/core'
import { MemoryAdapter } from '@operad/adapter-memory'
const runtime = createRuntime({ storage: new MemoryAdapter() })
const graph = await runtime.createGraph('claim-4521')
// Add what the agent knows
const claim = await graph.addObject({
type: 'claim',
data: { policy: 'HO-3-12345', status: 'open' }
})
// Record why it decided
await graph.recordDecision({
selectedAction: 'approve_claim',
alternatives: [
{ action: 'deny', rejected: 'evidence supports' }
],
confidence: 0.92
})
// Trace the full causal chain
const chain = await graph.traceBackward(decision.eventId) FOR AI ASSISTANTS
Paste this into Claude, ChatGPT, or your coding agent.
The best way to learn Operad is to let an AI build something with it. This prompt walks the agent through the core primitives — graphs, events, decisions, forks — using the real API.
No mocks. No abstractions. Just @operad/core and a working experiment.
You are an expert TypeScript developer.
1. Install the package:
npm install @operad/core @operad/adapter-memory
2. Build a small experiment that demonstrates:
- Creating a graph with objects and relations
- Recording a decision with alternatives
- Tracing the causal chain backward
- Forking the graph to explore an alternative
- Diffing the original vs the branch
3. Run it and explain:
- How the event log captures every mutation
- How traceBackward reveals the "why"
- How fork/diff enables counterfactual reasoning
Use the real API from @operad/core. Do not mock anything. THE PROBLEM
Agents need more than memory.
Existing tools solve one piece. None solve the whole picture.
Memory
Mem0, Zep, LangChain Memory
Store facts. Retrieve facts. But no causal history — you know what the agent remembers, not why it learned it or when it was last true.
Orchestration
LangGraph, CrewAI, AutoGen
Route tasks between agents. But state between steps is ephemeral — no immutable log, no branching, no replay from a prior state.
Observability
LangSmith, Braintrust, Arize
Watch agents from the outside. But the agent itself has no access to its own history — it can't act on what happened.
Operad
The append-only event log projected into a live graph. The agent's memory is the audit trail. Objects, relations, decisions, and causal chains — all queryable, forkable, and governed from inside the runtime.
INFRASTRUCTURE
The layer beneath your agent framework.
Operad is not an agent framework. It's the persistent state layer that any framework can use. It complements your existing stack — not replaces it.
- 01 Models GPT, Claude, Llama, Mistral
- 02 Tool frameworks Vercel AI SDK, MCP, function calling
- 03 Orchestration LangGraph, CrewAI, custom loops
- 04 Memory Mem0, Zep, vector stores
- 05 Operad Event-sourced graph runtime — this layer
CAPABILITIES
What you can build.
Auditable agents
Every mutation emits an event with causal links. Trace any decision back to its origin — the actual execution path, not a reconstructed explanation.
Forkable runs
Checkpoint at any event. Fork the graph. Explore a counterfactual path. Diff original vs branch. Keep the best outcome.
Reactive systems
Behaviors subscribe to event types. When a matching event fires, the behavior runs — creating chains of reactive logic driven by the event log.
Relations with meaning
Typed edges between objects — supports, contradicts, depends_on. Query patterns across the graph. Drive logic from structure, not just data.
Long-running memory
Facts persist across sessions. Staleness tracking flags what's gone cold. Health records show verification history. The agent knows what it knows — and what it's forgotten.
EXAMPLES
The event log is the agent.
Fork, explore, commit
Time-travel to any point in the event log. Fork a branch. Explore an alternative. Diff the outcomes. This is how agents do counterfactual reasoning — not by re-prompting, but by replaying and branching the actual state.
// Time-travel to event #42
const branch = await runtime.fork('claim-4521', {
atEvent: 42,
label: 'what-if-deny'
})
// Explore a different path
await branch.graph.recordDecision({
selectedAction: 'deny_claim',
alternatives: [{ action: 'approve', rejected: 'testing' }],
confidence: 0.65
})
// Compare outcomes
const diff = await runtime.diff('claim-4521', branch.id) const guard = behavior({
name: 'stale-data-guard',
on: ['object.stale'],
handler: async (event, graph, ctx) => {
ctx.propose({
target: event.payload.objectId,
action: 'reverify',
reason: 'Not verified in 30+ days'
})
}
})
// Human approves → object re-verified
await runtime.approve(patchId) Detect, react, govern
Behaviors watch the event stream. When stale data is detected, a behavior proposes a patch — not a direct mutation. A governance gate requires human approval. The agent suggests; a human decides.
SEE IT RUN
A claim flows through six behaviors.
Click each step to watch the graph build — or hit Play to run the full cascade. Every node is an object. Every edge is a causal link. Every event is logged.
import { createRuntime, behavior } from '@operad/core'
import { MemoryAdapter } from '@operad/adapter-memory'
// Behavior 1: Initialize with a goal
const initializer = behavior({
name: 'initialize-goal',
on: ['graph.created'],
handler: async (event, graph) => {
await graph.addObject({
type: 'task',
data: { description: 'Research competitor pricing', status: 'pending' }
})
}
})
// Behavior 2: Execute pending tasks
const executor = behavior({
name: 'execute-task',
on: ['object.created'],
where: { 'payload.objectType': 'task' },
handler: async (event, graph, ctx) => {
const result = await ctx.llm('Execute this task', event.payload.data)
await graph.addObject({
type: 'result',
data: { taskId: event.payload.objectId, output: result }
})
await graph.recordDecision({
selectedAction: 'completed',
confidence: 0.85,
reasoning: result.summary
})
}
})
// Behavior 3: Create follow-up tasks from results
const taskCreator = behavior({
name: 'create-follow-ups',
on: ['object.created'],
where: { 'payload.objectType': 'result' },
handler: async (event, graph, ctx) => {
const nextTasks = await ctx.llm('What follow-up tasks?', event.payload.data)
for (const task of nextTasks) {
await graph.addObject({ type: 'task', data: task })
}
}
})
const runtime = createRuntime({
storage: new MemoryAdapter(),
behaviors: [initializer, executor, taskCreator]
})
// One line starts the entire loop
await runtime.createGraph('research-agent')
// → initializer fires → executor fires → taskCreator fires → loop continues
// Every step is in the event log. Every decision is recorded. PATTERN
Task agent in behaviors.
Three behaviors wired through events — not function calls. The graph is the task queue. The event log is the execution trace.
- 01
initialize-goalcreates the first task object - 02
execute-taskreacts to new tasks, records decisions - 03
create-follow-upsreacts to results, spawns more tasks
The loop emerges from the event log. No explicit orchestration needed.
COMPARISON
How Operad compares.
| Feature | Operad | LangChain Memory | Mem0 | LangGraph |
|---|---|---|---|---|
| Event sourcing | ✓ | — | — | — |
| Causal chains | ✓ | — | — | — |
| Decision records | ✓ | — | — | — |
| Replay / checkout | ✓ | — | — | Partial |
| Fork / branch / diff | ✓ | — | — | — |
| Staleness tracking | ✓ | — | — | — |
| Reactive behaviors | ✓ | — | — | ✓ |
| TypeScript-native | ✓ | Python | Python | Python |
| Storage-agnostic | ✓ | Vector DB | Proprietary | Checkpointer |
| Open source | MIT | MIT | Closed | MIT |
ACKNOWLEDGMENTS
Inspired by
Operad stands on the work of researchers and builders who proved these patterns first.
ActiveGraph
arXiv:2605.21997
"The Log is the Agent: Event-Sourced Reactive Graphs for Auditable, Forkable Agentic Systems" — Yohei Nakajima (BabyAGI). Proved that event-sourced knowledge graphs are the right abstraction for agent state.
paperESAA
arXiv:2602.23193
"Event Sourcing for Autonomous Agents in LLM-Based Software Engineering" — Agents emit structured intentions; a deterministic orchestrator validates and persists events in an append-only log.
paperAgentGit
arXiv:2511.00628
"A Version Control Framework for Reliable and Scalable LLM-Powered Multi-Agent Systems" — Git-like rollback and branching for agent state with persistent checkpoints.
paperAtomix
arXiv:2602.14849
"Timely, Transactional Tool Use for Reliable Agentic Workflows" — Epoch-tagged calls, frontier-gated commits, and compensating actions for atomic agent operations.
paperFork/Explore/Commit
arXiv:2602.08199
"OS Primitives for Agentic Exploration" — Copy-on-write branch contexts with fork, explore, and first-commit-wins resolution for parallel agent exploration.
paperSagaLLM
arXiv:2503.11951 · VLDB 2025
"Context Management, Validation, and Transaction Guarantees for Multi-Agent LLM Planning" — Saga-pattern transactions with persistent memory and automated compensation.