Part I — How is a production agent engineered around an untrusted model?
Reference implementation: cognokratos/simple-agent-template, branch main, pinned in Source revisions.
Stack: Rust (Rig agent, gateway, MCP server), Keycloak, PostgreSQL, OpenTelemetry → MLflow, assistant-ui.
Historical implementation: the previous NVIDIA NeMo Agent Toolkit 1.9 agent is preserved at nat-1.9-final. The migration is part of the curriculum because the framework changed without moving the trust boundaries.
Part I is the foundation for the rest of the book. It starts from one observation: agentic AI is software engineering around a probabilistic decision-making component. Then, stage by stage, it asks why each next architectural component is needed.
The implementation itself has now become evidence for the lesson. The original version used NVIDIA NeMo Agent Toolkit. The current version uses Rig in Rust. The gateway, MCP capability boundary, database, identity rules, approval boundary, evaluation specification and telemetry contract survived the change. That is the point: frameworks are replaceable; trust boundaries are architecture.
What the system is
A customer-support agent over a small ticket database. A user signs in through Keycloak. A Rust gateway acting as a backend-for-frontend handles OIDC with PKCE, opaque sessions and CSRF, and mints the identity headers downstream services trust. The agent is a Rust service built on Rig. Rig owns the model/tool loop; explicit Rust code owns identity, tool policy, approval handling, state transitions and the input/output controls. Its tools live in a separate Rust MCP server, the only component besides PostgreSQL on the data network. The MCP server authenticates the agent with a service key and grants exactly the configured tools. Every request produces one OpenTelemetry trace, and four evaluation suites measure behaviour.
The sample application is read-only by default: its two tools,
search_tickets and get_ticket, only read. A state-changing action, changing
a ticket's priority, can be enabled as an opt-in. It then requires a signed
human approval. The trusted agent runtime signs it with a secret the model
never sees, and the MCP server verifies it at the point of mutation: it
consumes a single-use nonce, locks the row, re-derives the current state, checks
policy, and applies the change with an append-only audit record in one
transaction.
The current Rust agent also makes one distinction especially visible: a model proposal is not authority. A proposed tool call passes deterministic schema and policy checks before execution, and the MCP server remains authoritative for mutations. Intelligence does not imply authority.
What it does not do
The template's Limitations chapter is part of the curriculum. Among other things, it lists that there is no per-user data authorisation, no secrets manager, no migrations, no access control on the trace store, approvals are only in memory, and the configured overall request timeout is not yet enforced. Some guarantees are enforced by the database but still require a live-cluster check, such as nonce conflicts under real concurrency. Read Limitations before you adapt the template.
How this part is organised
- The learning path. Stages 0–10, from the model as a probabilistic component to the composed production architecture. Each stage names the failure it addresses and the deterministic boundary that contains it.
- Follow one request. One request through every trust boundary, with the code at each hop.
- Concepts. Eight concept chapters and the anti-patterns, which explain why each component exists.
- Labs. Ten hands-on labs: run, extend, break, evaluate, trace, add a mutation and an approval, then build your own domain agent.
- Challenges. Competency exercises without solutions.
- Reference. The precise how: architecture, security, approvals, guardrails, evaluation, observability, configuration, test scenarios, extension and limitations, plus the agent-service contract.
- Framework replacement as an architectural test. The template actually migrated from NAT to Rig/Rust. This chapter asks what changed, what did not, and why the migration is stronger evidence of portability than a side-by-side framework comparison.
- What survives, and where to go next. The properties that must hold whichever agent runtime you use, and a few external projects to explore after this part.
Running the labs
The full stack runs eight services: assistant-ui, the gateway, Keycloak,
PostgreSQL, the MCP server, the agent, the OpenTelemetry Collector and MLflow.
A Docker VM with about 8 GB of memory is a practical baseline; the model runs
outside that budget by default. You also need make, bash, Python 3, Node 22 or
newer for UI checks, and Rust 1.95 or newer for the agent's host-side tests and
labs that edit Rust code. The model endpoint is any OpenAI-compatible API. The
default is a local Ollama with qwen3:8b. See
Setting up each track.
What later parts take from here
| Later part | Builds on |
|---|---|
| II · Sophos | stages 0–3: model, loop, tool calling, MCP |
| III · ETF Research | the whole path; its code is derived from this template |
| IV · Arktos | stage 3 (capability boundaries), stage 8 (identity) |
| V · Tauros | the distinction between a model's capability and authority |