Skip to content

With a served model and tool calls in the engine, the system can act as well as answer. This pass builds an agent SDK in Go on the engine’s tool-call API: provider types, a tool registry with schema validation, the agent loop, a tool gate with a prompt-injection suite, and durable agent runs. It adds retrieval over the system’s own documentation, so the agent can answer questions about the system and cite its sources, and an evaluation runner with scorers, an LLM judge, and paired A/B experiments. The gateway gains a usage policy enforced once, at the edge, for every model and client.

Concepts from other sections (17)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

An optional second half post-trains the capstone model: supervised fine-tuning, DPO, GRPO with verifiable rewards, and distillation.

Learning objectives

  • Explain how the agent loop calls tools through the engine and why the tool gate blocks injected instructions.
  • Explain how retrieval, context assembly, and citations make an answer checkable.
  • Explain how the eval runner, scorers, judge, and A/B experiments compare two models with an interval.
  • Explain how the gateway enforces a usage policy for every request.

This pass needs Pass 9: the served capstone and the engine’s tool calls from Pass 7.

  1. Types, an OpenAI-compatible provider, and a retry wrapper. Afterwards you can explain the agent SDK’s types, the OpenAI-compatible provider, and which errors the retry wrapper retries.
  2. Tools, a registry, and JSON Schema argument validation. Afterwards you can explain how tools register and how arguments are validated against JSON Schema.
  3. The agent loop. Afterwards you can trace the agent loop from model call to tool execution and explain when it stops.
  4. The tool gate, the SQL safety gate, and the prompt-injection suite. Afterwards you can explain how the tool gate and SQL safety gate block unsafe calls and what the prompt-injection suite tests.
  5. Durable agent runs. Afterwards you can explain how AgentRun makes an agent run durable and replayable.
  6. RAG Ingest: Crawler, Chunker, Embedder, and Store. Afterwards you can explain how RAG ingest crawls behind an SSRF allowlist, chunks, embeds, and stores documents.
  7. Retrieval: BM25, Flat and IVF Vectors, RRF, and MMR. Afterwards you can explain how BM25, flat and IVF vector search, RRF, and MMR retrieve and rerank.
  8. Context Assembly, Citations, and the search_docs Tool. Afterwards you can explain how context assembly fits retrieved chunks into budget, attaches citations, and exposes search_docs.
  9. Eval runner. Afterwards you can explain how the eval runner executes a suite and records results.
  10. Agent evaluation scorers. Afterwards you can explain what each agent evaluation scorer measures.
  11. LLM judge with position control. Afterwards you can explain how the LLM judge controls for position bias.
  12. Paired A/B experiments. Afterwards you can explain how a paired A/B experiment estimates a difference with a confidence interval.
  13. Usage policy at the gateway. Afterwards you can explain the usage policy and why it is enforced at the gateway.
  14. Usage policy enforcement. Afterwards you can explain how the gateway enforces the usage policy and returns 451.
  15. The agent image and chart. Afterwards you can explain how the agent image and chart are built and deployed.
  16. Agent evals as tests. Afterwards you can explain how agent evals are written as tests and what they assert.
  17. What the System Does After Pass 10. Afterwards you can explain how the durable agent answers with citations and passes evals, policy checks, and prompt-injection cases.

These optional sections post-train the TinyStories model and end with a second capstone:

  1. Optimization problem set, part b: constrained optimization, duality, and DPO. Afterwards you can work every problem in the set and explain each answer.
  2. Supervised fine-tuning: chat rendering, assistant-only loss, packing. Afterwards you can explain how SFT renders chats, masks the loss to assistant tokens, and packs sequences.
  3. Direct preference optimization and IPO. Afterwards you can derive the DPO and IPO losses from the preference objective.
  4. Group relative policy optimization with verifiable rewards. Afterwards you can explain how GRPO computes group-relative advantages from verifiable rewards.
  5. Distillation with forward and reverse KL. Afterwards you can explain how distillation with forward KL differs from reverse KL.
  6. Capstone 2: post-trained TinyStories model. Afterwards you can explain how the post-trained TinyStories model is built and why it beats the base model on held-out preference tasks.

The stages are also in this pass’s manifest, path.tsv. Pass 11 releases the system as v1.0.0 and operates it.

Generated from path.tsv.

StageReadDone when
1Types, OpenAI-compatible provider, retry wrapper
28.1 Types, an OpenAI-compatible provider, and a retry wrapper
You can explain the agent SDK’s types, the OpenAI-compatible provider, and which errors the retry wrapper retries (ag.01).
2Tools, registry, JSON Schema argument validation
28.2 Tools, a registry, and JSON Schema argument validation
You can explain how tools register and how arguments are validated against JSON Schema (ag.02).
3Agent loop
28.3 The agent loop
You can trace the agent loop from model call to tool execution and explain when it stops (ag.03).
4Tool gate, SQL safety gate, prompt-injection suite
28.4 The tool gate, the SQL safety gate, and the prompt-injection suite
You can explain how the tool gate and SQL safety gate block unsafe calls and what the prompt-injection suite tests (ag.04).
5Durable agent runs (AgentRun)
28.5 Durable agent runs
You can explain how AgentRun makes an agent run durable and replayable (ag.05).
6RAG ingest: crawler with SSRF allowlist, chunker, embedder, store
27.1 RAG Ingest: Crawler, Chunker, Embedder, and Store
You can explain how RAG ingest crawls behind an SSRF allowlist, chunks, embeds, and stores documents (ag.06).
7Retrieval: BM25, flat and IVF vectors, RRF, MMR
27.2 Retrieval: BM25, Flat and IVF Vectors, RRF, and MMR
You can explain how BM25, flat and IVF vector search, RRF, and MMR retrieve and rerank (ag.07).
8Context assembly, citations, search_docs tool
27.3 Context Assembly, Citations, and the search_docs Tool
You can explain how context assembly fits retrieved chunks into budget, attaches citations, and exposes search_docs (ag.08).
9Eval runner
29.1 Eval runner
You can explain how the eval runner executes a suite and records results (ag.09).
10Agent evaluation scorers
29.2 Agent evaluation scorers
You can explain what each agent evaluation scorer measures (ag.10).
11LLM judge with position control
29.3 LLM judge with position control
You can explain how the LLM judge controls for position bias (ag.11).
12Paired A/B experiments
29.4 Paired A/B experiments
You can explain how a paired A/B experiment estimates a difference with a confidence interval (ag.12).
13Usage policy at the gateway
37.1 Usage policy at the gateway
You can explain the usage policy and why it is enforced at the gateway (ethics.05).
14Usage policy enforcement
25.6 Usage policy enforcement
You can explain how the gateway enforces the usage policy and returns 451 (gw.08).
15Agent image and chart
10.8 The agent image and chart
You can explain how the agent image and chart are built and deployed (dep.07).
16Agent evals as tests (R9)
3.9 Agent evals as tests
You can explain how agent evals are written as tests and what they assert (craft.23).
17What the system does after Pass 10
B.12.1 What the System Does After Pass 10
You can explain how the durable agent answers with citations and passes evals, policy checks, and prompt-injection cases.
18Optimization problem set, part b: constrained optimization, duality, and DPO
16.6 Optimization problem set, part b: constrained optimization, duality, and DPO
You can work every S-M10b problem and explain each answer.
19Supervised fine-tuning: chat rendering, assistant-only loss, packing
18.1 Supervised fine-tuning: chat rendering, assistant-only loss, packing
You can explain how SFT renders chats, masks the loss to assistant tokens, and packs sequences (L12.1).
20Direct preference optimization and IPO
18.2 Direct preference optimization and IPO
You can derive the DPO and IPO losses from the preference objective (L12.2).
21Group relative policy optimization with verifiable rewards
18.3 Group relative policy optimization with verifiable rewards
You can explain how GRPO computes group-relative advantages from verifiable rewards (L12.3).
22Distillation with forward and reverse KL
18.4 Distillation with forward and reverse KL
You can explain how distillation with forward KL differs from reverse KL (L12.4).
23Capstone 2: post-trained TinyStories model
A.2 Capstone 2: post-trained TinyStories model
You can explain how the post-trained TinyStories model is built and why it beats the base model on held-out preference tasks (C2).