System Design and Coding Interviews
Strong answers start by clarifying the goal and risk, choose the simplest design that works and say how failure is detected.
Use a repeatable frame: clarify goal and risk, define success, propose the simplest design, add tools and data, cover failure and security, then evaluation, monitoring and cost, and state assumptions. For coding, write a small correct solution, test the unhappy paths and explain your choices.
What you will learn: the answer frame, quick capacity estimates, six design questions with discussion points, a coding exercise, follow-up questions, architect cases and how to practice.
Prerequisites: What Is an AI Agent? Anatomy and Goals and Single-Agent, Router and Retrieval Patterns.
The examples run in November 2026 with Python 3.13 and only the standard library. Traffic, token counts, prices and the scripted model are invented. Questions on this page are practice material written for this site, not leaked or official questions from any employer.
Common formats
| Format | Assesses | Prepare by |
|---|---|---|
| Coding | Correctness, clarity, testing | Building small tools without help |
| System design | Trade-offs and failure thinking | Speaking through designs aloud |
| Project deep dive | What you really did | Knowing decisions, results and mistakes |
| Debugging | Method under uncertainty | Reading traces and forming hypotheses |
| Behavioral | Collaboration and judgment | Concrete stories with your role |
| Take-home | Realistic work | Time-boxing and documenting limits |
Employers differ. Ask what the format will be and whether AI tools are allowed, and follow the rule given.
A seven-step design frame
Clarifying questions that help
- Who uses it, how often and with what urgency?
- Does it only answer, or also change records?
- What is the worst outcome of a wrong action?
- Which systems hold the truth, and who may see what?
- How is correctness checked today?
- What are the limits on delay and cost?
Sizing on a whiteboard
Rough arithmetic shows where the pressure is. The program writes out one estimate. The central relation, Little's law, says that average work in progress equals arrival rate times time in the system.
"""Back-of-envelope sizing for an agent service (all inputs are assumptions)."""
from math import ceil
users, tasks_per_user, peak_factor = 20000, 3, 5
calls_per_task, in_tokens, out_tokens = 6, 4000, 500
seconds_per_call, tool_seconds = 2.5, 4.0
price_in, price_out = 1.00, 4.00 # invented, per million tokens
tasks_day = users * tasks_per_user
avg_rate = tasks_day / 86400
peak_rate = avg_rate * peak_factor
task_seconds = calls_per_task * seconds_per_call + tool_seconds
running = peak_rate * task_seconds # Little's law: L = rate x time
calls_minute = peak_rate * calls_per_task * 60
tokens_minute = calls_minute * (in_tokens + out_tokens)
cost_task = calls_per_task * (in_tokens * price_in + out_tokens * price_out) / 1e6
print(f"tasks per day {tasks_day:,}")
print(f"peak tasks per second {peak_rate:.2f}")
print(f"seconds per task {task_seconds:.0f}")
print(f"tasks in progress, peak {ceil(running)}")
print(f"model calls per minute {calls_minute:,.0f}")
print(f"tokens per minute {tokens_minute / 1e6:.1f} million")
print(f"model cost per task {cost_task:.3f}")
print(f"model cost per day {cost_task * tasks_day:,.0f}")
Output:
tasks per day 60,000
peak tasks per second 3.47
seconds per task 19
tasks in progress, peak 66
model calls per minute 1,250
tokens per minute 5.6 million
model cost per task 0.036
model cost per day 2,160
Modest user numbers produce dozens of simultaneous tasks and millions of tokens per minute, so provider rate limits and cost deserve attention before server capacity. In an interview, round freely, state each assumption and say which one you would measure first. Little's law holds for long-run averages; bursts need headroom, queues and limits. Capacity planning goes further.
Question 1: support agent with refunds
Discuss: identity of the customer, order lookup, policy retrieval, a refund tool with limits enforced by the service, approval above a threshold, idempotency, handoff, resolution measured by no repeat contact and protection against instructions hidden in messages. A strong answer separates advice from action.
Question 2: research assistant over company documents
Discuss: ingestion, permissions filtered at retrieval, chunking, hybrid search, citations checked against passages, freshness, an answer of "not found" and evaluation of retrieval separately from generation. See RAG Explained and Agentic RAG.
Question 3: coding agent in a repository
Discuss: isolated workspace, restricted network and secrets, tests as feedback, step and cost budgets, human review before merge, handling of untrusted repository text and measurement by merged changes that stay. See Coding Agent Architecture and Code Understanding.
Question 4: long-running procurement workflow
Discuss: durable state, waiting for people for days, expiry and revalidation of approvals, compensation after partial failure, version changes during a running process and audit records. See Durable Execution, Checkpoints and Approvals.
Question 5: multi-agent incident helper
Discuss: whether several agents are needed at all, read-only investigation first, shared state and ownership, conflicting findings, limits on parallel load against failing systems and who is allowed to change production. See Single-Agent vs Multi-Agent Systems.
Question 6: voice appointment agent
Discuss: latency budget across speech, reasoning and tools, interruption, confirming names and times, consent and recording notices, fallback to a person and testing across accents and noise. See Voice Agent Architecture and Real-Time Audio.
Coding exercise: a bounded loop
Task: write an agent loop that validates tool calls, survives errors, detects repeats and always stops.
"""Coding question: a bounded agent loop with validated tool calls."""
def run(model, tools, task, max_steps=5):
history, seen = [("task", task)], set()
for step in range(1, max_steps + 1):
action = model(history)
if action.get("type") == "answer":
return "done", action["text"], step
name, args = action.get("tool"), action.get("args", {})
if name not in tools:
history.append(("error", f"unknown tool {name}"))
continue
required, function = tools[name]
if set(args) != required:
history.append(("error", f"{name} needs {sorted(required)}"))
continue
key = (name, tuple(sorted(args.items())))
if key in seen:
return "stopped", "repeated the same call", step
seen.add(key)
try:
history.append(("result", function(**args)))
except Exception as error: # report, do not crash
history.append(("error", type(error).__name__))
return "stopped", "step limit reached", max_steps
def scripted(actions):
queue = iter(actions)
return lambda history: next(queue)
TOOLS = {"stock": ({"item"}, lambda item: {"pen": 12}[item])}
call = lambda **args: {"type": "call", "tool": "stock", "args": args}
done = {"type": "answer", "text": "12 pens"}
CASES = {
"happy path": [call(item="pen"), done],
"bad arguments": [call(name="pen"), call(item="pen"), done],
"tool failure": [call(item="ink"), {"type": "answer", "text": "stock unknown"}],
"repetition": [call(item="pen"), call(item="pen")],
"never ends": [call(item=str(i)) for i in range(9)],
}
for name, actions in CASES.items():
status, text, steps = run(scripted(actions), TOOLS, "How many pens?")
print(f"{name:<14}{status:<8}steps={steps} {text}")
Output:
happy path done steps=2 12 pens
bad arguments done steps=3 12 pens
tool failure done steps=2 stock unknown
repetition stopped steps=2 repeated the same call
never ends stopped steps=5 step limit reached
A scripted model makes behavior testable without any service. Points to raise: argument types are not checked, only names; argument values must be hashable; repeating a read after a change may be legitimate; error text should be informative without leaking secrets; side effects need idempotency keys and approval; and time and cost budgets belong beside the step limit. Naming these limits is often worth more than adding features.
More coding prompts to practice
| Prompt | Edge cases to test |
|---|---|
| Retry with backoff | Non-retryable errors, total deadline, jitter |
| Token budget for context | One item larger than the budget, required items |
| Parse structured output | Missing fields, wrong types, extra text |
| Approval gate | Changed arguments, expiry, double use |
| Rank fusion | Ties, items in one list only |
| Rate limiter | Bursts, clock changes, concurrency |
Follow-up questions to expect
- What happens if the model provider is slow or down?
- How do you stop the agent doing something twice?
- What can a malicious document cause?
- How do you know a new version is better?
- What would you cut to halve cost?
- Which part would you not automate?
Senior architect cases
| Case | Judgment being tested |
|---|---|
| Three teams built separate agent stacks | What to standardize, what to leave, and migration cost |
| Leadership wants full autonomy this quarter | Staged evidence, risk tiers and an honest alternative |
| A model is being retired in 60 days | Inventory, evaluation, compatibility and rollback |
| Costs tripled without more users | Traces, context growth, retries and loops |
| An agent exposed another user's data | Containment, evidence, notification duties and structural fix |
Describe how you would decide, who you would involve and what you would communicate. A confident single answer without questions is a weak sign. Reliability and migration gives background.
A short worked answer
Prompt: design an agent that updates customer addresses. First clarify: who requests, how identity is proven, which systems change and the harm if wrong. Success: the correct address in the system of record, confirmed to the customer. Simplest design: a form and a validated workflow, with a model only to understand free text. Tools: identity check, address validation and a single update service that enforces permissions. Failure: partial updates across systems need retries with keys and a visible pending state; account takeover risk calls for stronger verification and notice to the old contact. Evaluation: test messy inputs and impersonation attempts. Assumptions: low volume, one country. If volume or fraud risk is higher, the verification design changes. Suggesting that an agent may be unnecessary is a legitimate and often strong answer.
Self-assessment rubric
| Dimension | Weak | Strong |
|---|---|---|
| Framing | Starts drawing at once | Establishes goal, risk and measures |
| Simplicity | Many agents by default | Justifies each component |
| Failure | Happy path only | Detects, limits and recovers |
| Security | "Add guardrails" | Names boundaries and enforcement points |
| Evidence | "Test it" | Cases, metrics, release gate |
| Communication | Monologue | Checks direction and summarizes |
How to practice
- Record yourself answering in 40 minutes.
- Review against the rubric and note the first weak dimension.
- Build the riskiest part of one design to test your claims.
- Swap roles with a partner and ask follow-ups.
- Prepare four project stories: success, failure, disagreement and trade-off.
- Protect confidential details from current or past employers.
When you do not know
Say so, describe how you would find out and reason from principles. Inventing a product feature or number is far riskier than admitting a gap. If you realize an earlier statement was wrong, correct it.
Using forty minutes
| Minutes | Do |
|---|---|
| 0 to 5 | Clarify goal, users, actions and worst outcome |
| 5 to 8 | State success measures and rough scale |
| 8 to 18 | Draw the simplest design and walk one request through it |
| 18 to 28 | Go deep on the riskiest part, usually actions, data access or state |
| 28 to 35 | Failure, security, evaluation, monitoring and cost |
| 35 to 40 | Summarize decisions, assumptions and next steps |
The split is a practice aid. Follow the interviewer when they want to explore something else.
Trade-offs worth rehearsing
- Fixed workflow versus free agent loop: predictability against flexibility.
- One large model versus routing: simplicity against cost and testing burden.
- Synchronous versus background work: immediacy against durability.
- Retrieval at request time versus precomputed summaries: freshness against speed.
- Approval versus automation: safety against delay and review capacity.
- Managed service versus own runtime: speed to start against control.
For each, prepare one situation where you would choose either side.
A debugging round
You may be given a trace instead of a blank board. State what the system should have done, find the first step where reality departs from that, form two or three hypotheses and name the cheapest check that separates them. For a loop, look at what the model saw after each tool result. For wrong data, check identity, filters and freshness. For slowness, compare time in model calls, tools and queues before proposing a fix. Finish with a test that would catch the problem again.
Preparing project stories
| Part | Say |
|---|---|
| Situation | The problem and its constraints, briefly |
| Your role | What you personally decided and built |
| Choice | Options considered and why one won |
| Result | Measured outcome, or honestly that it was not measured |
| Learning | What failed and what you would change |
Take-home tasks
Read the instructions twice, note the time limit and ask about anything unclear. Deliver something small that runs, with setup steps, tests for unhappy paths and a short note on choices, limits and what you would do next. State which tools and assistants you used if allowed. Remove secrets and personal data. Stop at the agreed time and say what is unfinished; a clear boundary is better than a hidden extra weekend.
Common mistakes
| Mistake | Consequence | Instead |
|---|---|---|
| Naming tools instead of designing | No reasoning visible | Describe responsibilities first |
| Prompt as the security control | Unsafe design | Enforce in code and identity |
| No stop conditions | Runaway work | Budgets and repeat detection |
| Skipping evaluation | Unverifiable quality | Plan cases and gates |
| Silent assumptions | Misaligned design | State and test them |
| Memorized answers | Fails on follow-up | Practice trade-offs |
Checklist
- I can recite and apply the seven steps.
- I can estimate rate, concurrency, tokens and cost.
- I can write a bounded loop with tests unaided.
- I can explain enforcement of permissions.
- I have four true project stories.
- I know the stated interview rules on tools.
Frequently asked questions
Should I mention specific frameworks?
Mention those you know and why they fit, after describing the design. Show that your reasoning would survive a different choice.
How exact must estimates be?
Order of magnitude is usually enough. Clear assumptions and sensible conclusions matter more than precise arithmetic.
Is multi-agent design expected?
Only when roles, permissions or parallel work justify it. Explain why a single agent or workflow is not enough before adding more.
What if the interviewer disagrees?
Ask what constraint they have in mind, compare the options openly and change your answer if the argument holds.
References
- Anthropic: Building effective agents
- OWASP GenAI Security Project
- Google: Site Reliability Engineering book
Where to go next
MCP, RAG, Security and Evaluation Interviews
Practice topic questions.
Agent Pattern Catalog and Diagram Gallery
Review design patterns.
Agent Threat Model and OWASP Agentic Risks
Strengthen security answers.