Production Safety, Evaluation & Deployment

Production Agentic Systems & Interview Mastery

5 min read

Why Production Is the Hard Part

Building an agent that works in a demo is easy. Building one that works reliably at scale — handling thousands of users, managing costs, preventing safety violations, and degrading gracefully when things go wrong — is where the real engineering challenge lies.

This is also what separates L4 candidates from L6+ candidates in interviews. Anyone can describe a happy-path agent architecture. Senior engineers proactively identify failure modes, cost risks, and safety concerns before the interviewer asks.

The Five Production Challenges

1. Unpredictable Behavior

Unlike traditional software where the same input produces the same output, agents behave non-deterministically:

ChallengeExampleMitigation
LLM non-determinismSame question gets different tool callsSet temperature=0 for deterministic paths, use structured outputs
Tool side effectsAgent sends an email it shouldn't haveAction allowlists, confirmation gates for destructive operations
Cascading errorsOne bad tool result leads to a chain of wrong decisionsCircuit breakers, maximum error count per session
Prompt sensitivityMinor wording changes cause different agent behaviorRegression testing with golden datasets

2. Cost Explosion

Agents can consume tokens rapidly, especially in multi-step reasoning. The trap is that cost scales with the number of loop iterations, and the number of iterations is decided at runtime by a component that cannot be asked to be cheaper.

Model this before an interviewer asks you to. Look up the current per-token prices on your provider's pricing page and enter them — the defaults below are placeholders, not quotes:

What a multi-step agent actually costs

Prices change often; enter the current numbers from your provider's pricing page rather than trusting any figure printed in a course. The shape of the result is what matters: cost is roughly linear in loop steps, which is why an unbounded loop is a billing incident.

Loop steps per interaction6
Input tokens per step4,000
Output tokens per step400
Input price per 1M tokens$3
Output price per 1M tokens$15
Retry overhead15%
Requests per day5,000
Cost per interaction
$0
Monthly spend at this volume
$18,630
Share of cost from output tokens
33.3%
Input tokens billed per interaction
24,000
cost = steps × (input tokens × input price + output tokens × output price) ÷ 1M × retry factor

Two things to notice, because both come up in interviews. Raising the step limit from 6 to 20 more than triples the bill without any change to your code — which is why "max autonomous steps" is a cost control, not just a safety control. And input tokens usually dominate, because every step resends the accumulated context; that is what makes prompt caching and history compaction cost levers rather than micro-optimisations.

Cost control strategies:

  • Token budgets — Set a hard ceiling per request (e.g., 50K tokens max)
  • Model cascading — Use a smaller model for simple tool selection, larger model for complex reasoning
  • Prompt caching — Cache system prompts and tool definitions across requests
  • Early termination — Stop if confidence is high enough after fewer tool calls

3. Safety Guardrails

Agents need multiple layers of protection. The three layers exist because they fail differently: input guardrails can be talked around, action guardrails cannot — they sit between the model's intent and the thing that actually happens.

Three guardrail layers, and which one you would keep

Input guardrails — before the model sees it
Action guardrails — between intent and effect
Output guardrails — before the user sees it

Input guardrails:

  • Prompt injection detection (pattern matching + classifier)
  • PII detection and redaction
  • Topic boundary enforcement (stay within allowed domains)

Action guardrails:

  • Tool allowlist/blocklist per user role
  • Parameter bounds checking (e.g., max email recipients)
  • Confirmation required for destructive operations (delete, send, pay)

Output guardrails:

  • Content filtering for harmful/inappropriate responses
  • Factuality cross-check against retrieved sources
  • Format validation (structured output compliance)

4. Evaluation & Testing

Testing agents is fundamentally different from testing traditional software:

Test TypeWhat It TestsHow
Unit testsIndividual components (tool executor, validator)Standard unit testing frameworks
Integration testsAgent + tools working togetherMock LLM with predetermined responses
Behavioral testsEnd-to-end agent behaviorGolden test datasets with expected outcomes
Adversarial testsSafety under attackPrompt injection attempts, edge cases
Regression testsNo degradation after changesRun golden dataset, compare scores

Key metrics for agent quality:

  • Task completion rate — Does the agent achieve the user's goal?
  • Tool call accuracy — Does it call the right tools with correct parameters?
  • Latency (P50/P95/P99) — How long does the full agent loop take?
  • Cost per interaction — Average token cost per user request
  • Safety violation rate — How often does the agent violate guardrails?
  • Hallucination rate — How often does the agent make unsupported claims?

5. Observability

You need to trace every decision the agent makes:

# Structured log for agent observability
{
    "request_id": "req_abc123",
    "user_id": "user_456",
    "timestamp": "2026-02-21T10:30:00Z",
    "event": "tool_call",
    "tool_name": "search_docs",
    "arguments": {"query": "refund policy"},
    "latency_ms": 245,
    "tokens_used": 1200,
    "cost_usd": 0.0024,
    "guardrail_flags": []
}

Essential dashboards:

  • Request volume and error rate over time
  • Token usage and cost breakdown by agent/tool
  • Latency percentiles (P50, P95, P99)
  • Safety violation rate and guardrail trigger frequency
  • Tool call distribution (which tools are used most?)

Interview Mastery: The Meta-Skills

Beyond technical knowledge, your interview performance depends on how you communicate:

Communication Cadence

The best candidates follow a predictable rhythm. The timings assume a 45-minute round — compress proportionally, but never skip the first two stages, which are the ones that stop you designing the wrong system for 40 minutes.

How to spend a 45-minute agent design round

Restate the problem · ~30 sec

"So we need an agent that…" Cheap insurance. If your restatement is wrong, you find out now instead of at minute forty.

Clarifying questions · ~2 min

Scope, scale, latency budget, what the agent is allowed to do without a human. Ask two or three real ones — questions whose answers would change your design.

State your approach · ~1 min

Name the framework you are about to apply before applying it, so the interviewer can redirect you early and cheaply.

High-level architecture · ~5 min

Components and data flow, end to end. Resist detail here — depth is the next stage, and detail spent now is usually spent on the wrong component.

Deep dive · 15–20 min

Two or three components, chosen with the interviewer. This is the bulk of your signal: tool design, state, recovery, coordination.

Production considerations · ~5 min

Failure modes, cost ceiling, guardrails, observability, evaluation. Reach this stage unprompted — candidates who need to be asked have already shown their level.

Summarise trade-offs · ~2 min

What you chose, what you rejected, and what would make you choose differently. The last sentence is the one that gets repeated in the debrief.

Handling "I Don't Know"

It's better to say "I'm not sure about the specific implementation, but here's how I'd approach figuring it out" than to make something up. Interviewers respect intellectual honesty.

Common Mistakes

MistakeBetter Approach
Jumping straight to implementationStart with requirements and architecture
Ignoring failure modesProactively mention what can go wrong
Forgetting about costAlways discuss token budgets and model cascading
Over-engineering the solutionStart simple, add complexity only when needed
Not asking clarifying questionsAsk 2-3 questions before designing anything
Monologuing for 10+ minutesCheck in with the interviewer regularly

What's Next?

Five agent systems built, and the patterns behind the rounds that decide these interviews. One closing thought before you go and use it.

Everything in this course has a shelf life except the reasoning. The frameworks in Module 1 will be replaced — one of them already was, mid-course-life, when OpenAI retired Swarm in favour of the Agents SDK. Context windows will grow again. Prices will move. What survives is the habit the design round is really testing: naming the trade-off you accepted, and knowing what breaks when the model is wrong.

So when you prepare, prepare the questions rather than the answers. And when an interviewer asks about a framework you have not used, the strong reply is not a bluff — it is "I haven't used it; here is the pattern I'd expect it to implement, and here's what I'd check first."

Continue your interview preparation:

  • AI System Design Interviews — Deepen your AI architecture knowledge with RAG system design, LLM application patterns, and production reliability
  • LLM Engineer Interviews — Master the LLM fundamentals that power every agent: transformers, fine-tuning, evaluation, and production optimization

Build real systems:

  • Build a Production REST API — Build a complete production API from scratch — the backend foundation that agentic systems run on
  • Advanced AI Agents — Explore multi-agent MCP integration, long-running agents, and enterprise deployment patterns

Good luck with your interviews. :::

Quiz

Module 5 Quiz: Production Safety, Evaluation & Deployment

Take Quiz
Was this lesson helpful?

Sign in to rate