Skip to content
AgenticAIWiki
  1. Learn
  2. Part 13
  3. 72. Rollouts and incident response
  4. 72.7

Lesson 72.7 · 7 of 7 · 10 min read · Reviewed 24 Nov 2026

Reference architecture: an AI system end to end

By the end, you can

  • Draw an end-to-end reference architecture for a production AI feature or agent.
  • Place each guardrail, store and pipeline from this course where it belongs, and say why.

Each chapter so far zoomed in on one part. This lesson zooms out. Here is one reference architecture for a production assistant or agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done., with every part tied back to where the course teaches it. Your system will drop some boxes and merge others, but you should be able to say where each concern lives.

The picture

 User
  |
  v
[1 Edge]  web or chat app, sign-in, streaming UI, feedback buttons
  |
  v
[2 Orchestrator]  workflow or agent loop: routing, state, limits, approvals
  |        |                 |                      |
  |        v                 v                      v
  |   [3 Tools]        [4 Retrieval]          [5 Memory and sessions]
  |   APIs, MCP        index, reranker,       session store, notes,
  |   servers, sandbox  document access rules  long-term memory
  |
  v
[6 AI gateway]  identity, quotas, routing, redaction, caching, logs, failover
  |
  v
[7 Models]  hosted APIs in two regions, plus a small or self-hosted model

[8 Observability and evals]  traces from every box -> online evals, golden sets, CI gates
[9 Release and governance]   versioned prompts and tools, flags, canaries, audit trail

Boxes 8 and 9 aren’t on the request path. They wrap everything else.

Each box, and where it’s taught

# Box Its job What goes wrong without it Course
1 Edge Authenticates the user, streams the reply, collects feedback Slow-feeling UI, no way to learn from users 68.1, 32.x
2 Orchestrator Runs the workflow or agent loop; owns turn limits, budgets, deadlines and human approval steps Runaway loops and unchecked actions 40 to 45, 52
3 Tools Do the real work behind narrow, well-described interfaces; risky ones need approval; code runs in a sandbox Excessive agency, data leaks 33, 34, 35, 37.5, 65.5
4 Retrieval Finds the right passages, filtered by what this user may see, before similarity search Wrong or leaked answers 21 to 26
5 Memory and sessions Keeps conversation state, notes and long-term facts, with retention and deletion rules Agents that forget, or remember what they shouldn’t 54 to 57, 61
6 AI gateway One choke point for every model call Every team reinvents keys, budgets and logging, differently below
7 Models A primary model, a cheaper model for easy routes, and a fallback region or provider Single point of failure, overspend 71.2, 70.3
8 Observability and evals Traces every model and tool call; samples traffic for online evals; feeds failures into golden sets Silent quality drift 16 to 20, 67
9 Release and governance Versions prompts, tools and models together; rolls out behind flags and canaries; keeps the audit trail Changes you can’t explain or undo 72, 66

The AI gateway, in more detail

The gateway is the box most teams add late and wish they’d added first. It is a thin service, bought or built, that every model call goes through:

Concern What the gateway does
Identity Calls are made with the gateway’s credentials. Teams and agents get their own identities (65.10), never raw provider keys
Quotas and budgets Per team, tenant and feature, with token-bucket limits under the provider’s rate limit (69.2)
Routing Picks a model by route, cost and health: small model for easy work, fallback provider on errors (71.2)
Redaction Removes or tokenises personal data before text leaves your network, if policy requires it (67.3)
Caching Response cache for safe repeats; keeps prompt prefixes stable so provider caches hit (70.1)
Logging One trace span per call with model, tokens, cost and latency, in OpenTelemetry form (67.7)
Guardrails Input and output classifiers that every team shares (64)
Failover Circuit breakers and region or provider fallback (70.3)

Keep the gateway boring. It should not hold business logic or prompts; those belong to the orchestrator, versioned with the feature.

Where each guardrail sits

Guardrail Box
Sign-in, consent, delegated user tokens 1 and 3 (65.10)
Input classifiers, PII redaction 6
Turn, token and time limits; human approval 2
Least-privilege tools, sandbox, network allow-lists 3
Document access filters 4
Output validation and schemas 2 (14)
Untrusted content marked as data, never instructions 2 and 3 (65.2)
Audit log of who did what 6 and 9 (66.1)

The feedback loop

The arrows that matter most aren’t on the request path:

  1. TracesTrace: A record of everything that happened during one request or agent run, as a tree of timed steps. from every box flow into one store (67).
  2. Online evalsEval: A repeatable test that measures how well an AI system performs on a set of cases with defined success criteria. score a sample of real traffic; bad cases and thumbs-down become golden-set cases (17, 67.4).
  3. Every change to a prompt, tool, model or index runs the eval gate in CIContinuous integration (CI): Automatically building and testing code on every change, usually in a hosted pipeline. (20).
  4. Changes ship behind flags and canariesCanary release: Releasing a change to a small share of traffic first and watching metrics before rolling it out further., with a kill switch (72.2, 72.3).
  5. Incidents end in a post-mortem and new eval cases (72.5).

Without this loop, the architecture above works on launch day and then slowly gets worse.

Adapting it

  • A single extraction feature: boxes 1, 2 (a short workflowWorkflow: A system where LLM calls and tools follow a path defined in code, rather than chosen by the model.), 6, 7 and 8. No tools or memory.
  • An internal coding agent: heavy on 3 (sandboxSandbox: An isolated environment that limits what code or an agent can reach, such as files, network or credentials., repo tools) and 2 (limits, approvals), light on 4.
  • A regulated customer-facing assistant: everything, with extra weight on 4’s access filters, 6’s redaction, and 9’s audit trail and data residencyData residency: A requirement that data is stored or processed in a particular country or region. (70.4).

Key points

  • A production AI system is mostly ordinary software around the model: an edge, a gateway, an orchestrator, tools, data and a feedback loop.
  • An AI gateway is the one place every model call passes through: identity, quotas, routing, redaction, caching, logging and failover.
  • The orchestrator owns the loop and its limits; tools sit behind least privilege and approvals; retrieval and memory are separate stores with their own access rules.
  • Traces feed evals, evals gate releases, and releases roll out behind flags. That loop is what keeps quality from drifting.
Hands-on labOn your own machine

Draw the reference architecture for your system

Map one real or planned AI feature onto the nine boxes of the reference architecture and find the gaps.

You will have: A diagram of your system with each box filled in or marked missing, a guardrail placement table, and the three gaps you would close first.

Steps

  1. Pick one AI feature or agent you run or plan to build.
  2. Draw the nine boxes and write what fills each one in your system, or mark it missing.
  3. Fill in the guardrail table: for each guardrail, which box enforces it today.
  4. Trace one request end to end, and one failure: a model region going down or a prompt change that lowers quality.
  5. List the three missing pieces that would hurt most, with the lesson that covers each.

Done when

  • Every box is either filled in or marked missing with a reason.
  • The traced failure has a named box that detects it and one that recovers from it.
  • The three gaps are ordered by risk, not by effort.
Quick checkFive product teams each call model APIs directly with their own keys. Security wants PII redaction, finance wants per-team budgets, and SRE wants failover between regions. Where should these controls live?
How sure are you?
Pick an answer and how sure you are

Finished the chapter? Take the chapter check.