Agent Substrate

Core Concepts

This section explains how Agent Substrate works — not the API surface, but the ideas behind it. Read it like a map: each page takes one concept, shows the problem it solves, and walks through how the framework implements it.

If you only read one page, read The Agent Model. Everything else builds on it.


The one-paragraph mental model

In Agent Substrate, an agent is not an object you call. It is an address you send messages to. The runtime receives the message, schedules a run, and drives the agent's reasoning loop. Every step the agent takes — calling the model, invoking a tool, spawning a sub-agent — is written to an append-only event log and guarded by a journal, so a crashed run can be replayed without repeating side-effects. Along the way, middleware wraps each model call, guardrails can block unsafe content, and risky tools can pause for human approval and resume later. Old conversation turns are kept by a history provider and trimmed by a compaction pipeline before they reach the model.

diagram
Rendering diagram…

The concept map

Foundations — read these in order

#ConceptThe question it answers
1The Agent ModelWhat is an agent, and how does a message become a running reasoning loop?
2DurabilityHow does a run survive a crash without re-charging the card or re-sending the email?
3ToolsHow does an agent take actions in the world, and how are risky ones controlled?
4Memory & ContextWhat does the agent remember, and how does old history fit in a finite window?

Control & safety

ConceptThe question it answers
Human-in-the-LoopHow does an agent pause for a human to approve a sensitive action, then resume?
MiddlewareHow do I wrap every model call with caching, retries, validation, or logging?
GuardrailsHow do I block prompt injection, PII leaks, or unsafe output?
Supervision & BudgetsHow do I stop a multi-agent system from spawning forever or burning the budget?
HooksHow do I observe the run loop without modifying agent code?

Advanced memory — three orthogonal strategies

These solve different failure modes and can run together. Start with Memory & Context, then go deeper:

StrategyHow it recallsBest for
Vector MemoryEmbed + cosine searchFuzzy semantic recall over large histories
Graph MemoryEntity nodes + relationship traversalStructured facts, constraints, decisions
Paged MemoryExplicit pages + index + agent-controlled retrievalFull-fidelity recall; the agent decides what to load

How the layers fit

Every concept on these pages lives in a specific architectural layer. The rule is simple: higher layers import from lower ones, never the reverse (enforced in CI by uv run lint-imports).

diagram
Rendering diagram…

integrations, infrastructure, and serving sit orthogonal to this stack — they implement kernel Protocols (LLM providers, Postgres/Redis backends, the FastAPI shells) and wire everything together at startup.