/ladder/l4/

L4 · Production

Memory, tools, runtime, governance, evals.

This is the floor every other rung was already standing on. We present L4 last because skipping it is the #1 reason agent prototypes die on contact with Tuesday — but conceptually, it is the foundation, not a final step.

The substrate

Every rung was leaning on this the whole time.

L1, L2, and L3 each pull from the operational layer beneath them. The spine is L4; each floor above annotates the L4 patterns it depends on.

L4 · PRODUCTIONMemory, tools, runtime, governance, observabilityL4 only ·episodic · adapter · actor model · audit trail · cost trackingL3 · MULTI-AGENTSpecialists, supervisors, swarmsuses L4 ·memory · A2A · HITL · tracingL2 · WORKFLOWSequential, routing, parallel, loopuses L4 ·DAG · checkpointing · HITL · LLM-judgeL1 · SINGLE AGENTReAct, Plan-and-Execute, Reflexionuses L4 ·function calling · MCP · tool registry · sandbox

Anatomy

What L4 is made of.

Five layers — Memory, Tools, Runtime, Governance, Observability — each a subdomain with its own primitives, its own failure modes, and its own answer to a different operational question.

  • Memory · What persists

    Working state, long-term memory, vectors, checkpoints.

    The pieces that survive past a single turn or a single run. Conversational, episodic, semantic, working — each with its own access pattern and bleed risk.

  • Tools · How the system acts

    Registry, MCP, A2A, sandboxes.

    The surface through which an agent reaches into the world. A registry catalogs capabilities; MCP and A2A standardize transport; sandboxes contain the blast radius.

  • Runtime · How it runs

    DAGs, schedulers, durable execution, retries.

    What makes a workflow resumable, restartable, and idempotent. The infrastructure layer that turns a graph into a service.

  • Governance · What it won't do

    HITL gates, audit trails, schema validation.

    The constraints that decide what gets through and what gets stopped. Where the system answers to people other than its operators.

  • Observability · How you see inside

    Traces, evals, judges, cost tracking.

    The telemetry that turns "it broke" into a diagnosis. Without this layer, every other layer is a black box.

Subdomains & patterns

Five layers. 34 patterns.

Each subdomain is a different operational question — memory, tools, runtime, governance, observability — and carries the production patterns that answer it. Together they are what L1, L2, and L3 were leaning on the whole time.

Memory architecture

What persists.

How conversation history, completed episodes, and structured knowledge are stored and retrieved across turns, runs, and sessions.

Where L3 systems leak across users and L2 workflows accumulate stale context. The choice between shared scratchpad and per-agent state is decided here.

7patterns
  • Conversational Memory

    The running message history of a session, kept in context so the agent can reference prior turns.

    LangGraphOpenAI Agents SDKAutoGen / AG2Microsoft Agent Framework+1
  • Episodic Memory

    Completed task episodes — input, plan, outcome — persisted so the agent can recall similar cases.

    LangGraphCrewAIAutoGen / AG2
  • Semantic / Vector / Graph Memory

    Long-term factual knowledge indexed in a vector or graph store for similarity retrieval.

    LangGraphLlamaIndexMicrosoft Agent Framework
  • Working Memory / Scratchpad

    A short-lived per-task buffer the agent uses while reasoning. Wiped between runs.

    LangGraphOpenAI Agents SDKCrewAI
  • Virtual Context Management

    The agent pages facts between a resident context tier and an external store, like an OS swapping RAM and disk.

    LettaMem0ZepLangChain / LlamaIndex
  • Recorder

    Captures every observation and tool result so a run can be replayed deterministically.

    LangGraphLangSmith
  • Skill Build

    Extracts repeatedly-used procedures into reusable skills the agent can invoke by name.

    Voyager-stylecustom

Tool integration

How it acts.

The surface through which the agent reaches into the world — function calling as the primitive, MCP and A2A as the transport, registries and adapters for scale.

Every L1 ReAct loop and every L3 specialist eventually sits behind a tool registry. Without one, the tool surface explodes and selection accuracy collapses.

8patterns
  • Tool Registry

    A central catalog of tools alongside schemas, permissions, and versions. The antidote to tool explosion.

    LangGraphOpenAI Agents SDKMicrosoft Agent FrameworkGoogle ADK+1
  • A2A Protocol

    Agent-to-Agent — Google's open protocol for cross-framework agent discovery and messaging.

    Google ADKMicrosoft Agent Framework
  • Adapter Pattern

    Wraps a legacy API or library in a thin tool-shaped interface the model can call.

    All
  • Capability Routing

    Selects which tool to invoke by capability tag rather than by name. Decouples caller and provider.

    LangGraphMicrosoft Agent Framework
  • Permission-scoped Tools

    Tools that carry an explicit permission tag enforced at the harness, not the prompt.

    LangGraphOpenAI Agents SDK
  • Agentic RAG

    The agent decides whether, when, and how to retrieve — reformulating queries and grading results — instead of retrieving once unconditionally.

    LangGraphLlamaIndex

Runtime architecture

What makes it durable.

The infrastructure that turns a graph into a service: DAG execution, checkpointing, retries, actor mailboxes, event buses.

L2 workflows die without checkpointing. L3 multi-agent systems can't scale without an actor model or a pub/sub mesh. Production demands resumability.

6patterns
  • Actor Model

    Each agent is an actor with its own mailbox and supervisor — concurrency without shared state.

    RayAkka-stylecustom
  • Event-driven Choreography

    Agents publish events to a bus; subscribers react. No central orchestrator decides.

    KafkaNATSAWS Strands
  • Saga / Compensation

    Long-running multi-step actions with explicit compensation handlers for partial failure.

    LangGraphTemporal
  • Pub/Sub Agent Mesh

    Agents discover each other through a broker; messages route by topic.

    KafkaNATScustom

Governance & safety

What it won't do.

The constraints, gates, and validators that decide what gets through and what gets stopped. The layer that answers to people other than the operators.

HITL gates pause for approval. Sandboxes contain blast radius. Schema validation rejects malformed state. Audit trails make every decision non-repudiable.

9patterns
  • Sandbox Execution

    Untrusted code runs in a sealed environment so side-effects can't escape. Where CodeAct actually executes.

    PyodidegVisorDockerE2B
  • Output Validation / Schema Enforcement

    Pydantic-style validation on every node output. Reject and retry on schema failure; never inherit corrupted state.

    LangGraphPydantic AIAll
  • Least Privilege Agent

    Each agent gets the minimal tool surface its role requires. The antidote to permission sprawl.

    All
  • Audit Trail

    Append-only log of every decision, tool call, and message. Non-repudiable across time.

    LangSmithcustom
  • Controller

    Polices the agent's actions against policy. Stops or modifies calls that violate rules.

    LangGraphcustom
  • Integrator

    Gathers and harmonizes outputs from multiple specialists before downstream propagation.

    LangGraphcustom
  • Multimodal Guardrails

    Filters and classifiers on inputs and outputs across text, image, and audio modalities.

    Llama GuardNeMo Guardrailscustom
  • Statistical Guardrails

    Numeric reject/allow gates: cosine-distance z-score for semantic drift, token entropy for low-confidence fabrication.

    customNeMo GuardrailsGuardrails AI

Observability & evaluation

How you see inside.

The telemetry that turns 'it broke' into a diagnosis: traces, judges, evals, cost accounting. The difference between a debuggable system and one you can only rerun.

Without distributed tracing, every L3 failure is archaeology. Without evals, you can't tell if a prompt change made things better or worse.

4patterns
  • Token / Cost Tracking

    Per-call token and dollar accounting. Budgets enforced at the harness level, not after the fact.

    LangSmithAll
  • Integration Tests for Agents

    Replayable test suites that exercise the agent end-to-end against fixtures and recorded traces.

    LangSmithPromptfoo

Anti-patterns

Ways this rung goes wrong.

  • #03

    SQLite Under Concurrency

    SymptomWrite locks serialize everything. Timeouts under load. Session bleeding.

    FixAsyncPostgresSaver. Compose thread IDs as user×session.

  • #07

    Cascading Security Failures

    from L3

    SymptomA poisoned doc in a shared index contaminates every downstream consumer. Prompt injection propagates via handoffs.

    FixTreat every agent-to-agent message as a trust boundary. Partition knowledge bases by trust level.

Frameworks

What you build this on.

Deep dive

The last rung is also the spine.

You have just climbed the ladder, and the rung at the top doubles as the spine that runs down the side of every rung below it. Every L1 agent you've written has already pulled patterns from L4: it kept working memory in a context window, it called tools through some kind of registry, it ran on a runtime, and — if you were diligent — it emitted traces. The five subdomains named on this page are not new territory; they are what L1, L2, and L3 have been leaning on the whole time.

The ladder presents L4 last for a single pedagogical reason: skipping it is the most common cause of agent prototypes dying on contact with production. A reader told about L4 first but not about L1 has no concrete system in which production concerns matter. A reader who has built an L3 multi-agent system without memory architecture, sandboxes, HITL gates, or distributed tracing will learn the hard way that the spine was always load-bearing.

There is no “L5.” The work of L4 is to push the operational discipline of this layer sideways into L1, L2, and L3 — to treat memory architecture, tool surfaces, runtime guarantees, governance, and observability as concerns of the system from the first prompt onward, not concerns to bolt on once it works in a demo. The discipline of treating production as a spine that touches every rung is what survives Tuesday.

You've reached the floor

The ladder isn't a hierarchy — it's a loop.

L4 isn't the summit; it's the ground every other rung stands on. A production system threads all four: an L1 loop, wired into L2 flow, coordinated as L3 specialists, running on the L4 substrate. Climb back down and read each rung knowing what holds it up.

Back to L1 — Single Agent

References

Where this rung was first written down.

The L1–L4 ladder is a didactic construct of this project — a way to sequence the catalog, not an external model. Its workflow-vs-agent seam (L2↔L3) follows Anthropic's Building Effective Agents (2024); each rung's patterns carry their own primary references.

Search

Search patterns, frameworks, and pages.