Production Safety, Evaluation & Deployment

Production Agentic Systems & Interview Mastery

7 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 callsConstrain the shape of the output (tool schemas, structured outputs) and make the effects safe to repeat — not the sampling dials, see below
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

The answer that is no longer available: temperature = 0

This is worth knowing because it is still the reflex answer in this round, and it is now wrong twice over.

It is wrong mechanically: Anthropic lists temperature, top_p and top_k under API parameter deprecations, and on Claude Opus 4.7 and later, setting any of them to a non-default value returns a 400 error. The Python SDK removed the parameters outright at v1.0, so passing one raises TypeError before a request is even sent.1

And it was wrong before that, which is the part worth saying out loud in an interview. Anthropic's own migration guidance states that if you were using temperature = 0 for determinism, it never guaranteed identical outputs on prior models.1 The parameter narrowed the sampling distribution; it did not pin the answer. What made repeated runs look stable was usually a prompt tight enough to admit only one sensible answer — and that is a property of the prompt, not of the dial.

So an agent is a system with a genuinely non-deterministic component in it, and the engineering question is not how to remove the non-determinism but which layer absorbs it:

Three answers to "how do you make the agent deterministic?"

no longer available

Pin the sampler

What it constrainsWhich token gets picked
Status400 on current Claude models; TypeError in the Python SDK
Did it ever workNo — the vendor says it never guaranteed identical output
Pros
  • One line, no design work, which is exactly why it became the reflex answer
  • Did genuinely reduce variation on the models that accepted it
  • Knowing it was retired — and that it never delivered determinism — is itself a signal in the round
Cons
  • Rejected outright by current models, so any code carrying it is already broken
  • It narrowed the distribution and never pinned the output, so the guarantee was always imagined
  • Encourages treating variation as a config problem, which stops you designing for it at all
where most of the win is

Constrain the output shape

What it constrainsThe set of things the model is allowed to emit
MechanismTool schemas, structured outputs, enums over free text
Failure it removesUnparseable or out-of-range tool arguments
Pros
  • Turns an open-ended generation into a choice from a finite set, which is testable
  • The validator, not the model, decides what reaches your tools
  • Survives model swaps — the schema is yours, not the provider's
Cons
  • Constrains the arguments, not the *decision* — the model can still pick the wrong valid tool
  • A schema too tight forces the model into a bad option rather than into an error
  • Says nothing about how many times the loop runs, which is where the cost lives
the senior answer

Make repetition harmless

What it constrainsThe blast radius of running the same step twice
MechanismIdempotency keys, dry-run mode, confirmation gates, replayable traces
Failure it removesThe retry that sends the email a second time
Pros
  • Holds regardless of which model you are on or how it was sampled
  • The only one of the three that survives a retry, a replay, or a crash mid-loop
  • Makes the trace the source of truth, which is what you need for debugging anyway
Cons
  • Real design work in every tool you expose, not a setting you switch on
  • Idempotency keys have to be threaded through systems you may not own
  • Does nothing about answer *quality* varying — that is still an evaluation problem

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)

And the one that is structural rather than a filter: channel separation. All three layers above are things you add. Channel separation is a decision about how the prompt is assembled: keep instructions and untrusted data in distinguishable places, mark retrieved documents, tool results and user-supplied text as data explicitly, and never let content that arrived from outside the system be concatenated into the instruction slot.

It is worth naming separately because it is the only measure on this page that addresses the cause rather than the symptom. Prompt injection works because instructions and data share one channel — a model reading a retrieved document has no protocol-level way to know that the sentence "ignore your previous instructions" is quoted content rather than a directive from you. A detector guesses at the difference after the fact; separation removes the ambiguity that the guess is compensating for.

It does not eliminate the risk on its own — a sufficiently persuasive payload can still be followed — which is exactly why the action layer still has to hold independently. Say both in the round: the structure narrows what an attacker can attempt, the allowlist bounds what succeeds if they manage it anyway.

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.

Footnotes

  1. Anthropic, Model deprecations — API parameter deprecations. The table lists temperature, top_p and top_k as deprecated on Claude Opus 4.7 and later, returning "a 400 error when set to a non-default value", and notes that the Python SDK v1.0 and later removes them so passing them raises a TypeError. The determinism point is in the migration guide. ::: 2

Quiz

Module 5 Quiz: Production Safety, Evaluation & Deployment

Take Quiz
Was this lesson helpful?

Sign in to rate