Design an Agentic System
Understanding the Problem
🤖 What is an agentic system? An agent is an LLM that runs in a loop: it reads a goal, decides on an action, calls a tool (search an index, query a database, issue a refund), reads the result and decides what to do next, until the task is done. An agentic system, or agent platform, is the infrastructure that lets many teams build agents like this and run them in production safely: it owns the loop, the tools, the state, the permissions and the record of what every agent did.
You'll hear this question in several forms: "design an agent platform," "how would you take an agent from demo to production," "design a multi-agent system," or "how do you keep an agent from leaking PII." They are the same problem. A demo agent is a while loop around a model API and ten lines of tool code. A production agent needs everything around that loop: durable execution, scoped credentials, guardrails, memory with a retention policy, traces, evals and a budget. We'll design the platform, and use a customer-support agent (look up orders, issue refunds, update addresses) as the running example.
Functional Requirements
Agent platforms can sprawl into "build an AI company," so be explicit that we're designing the runtime and the controls around it, not any one agent's prompt.
Core Requirements
- Developers should be able to define an agent (model, instructions, tools, policies), version it and deploy it.
- Users should be able to give an agent a task, or talk to it, and have it carry out multi-step work by calling tools, with progress streamed back.
- Agents should keep state across steps of a run and across sessions (memory), within clear limits on what is stored.
- Operators should be able to require human approval for sensitive actions, see a full trace of every run, evaluate agents before shipping them and cap what they cost.
Below the line (out of scope)
- Training or fine-tuning the underlying models (see LLM Fine-Tuning).
- Serving the models themselves. We'll call models through a gateway (see LLM Gateway).
- A no-code agent builder UI. We'll assume agents are defined in config or code.
Non-Functional Requirements
Ask your interviewer how big the platform is. We'll assume 300 agents from about 40 teams, running 1M runs a day. A typical run makes 10 model calls and 8 tool calls; most finish in under a minute, but some (research, data migrations) run for hours and wait on people.
Core Requirements
- The system must not lose a run or repeat a side effect when a worker crashes mid-run. A refund issued once must not be issued twice on retry.
- Agents must have least privilege: an agent can only do what its tools allow, on behalf of the user who started it, and never with more access than that user has.
- The system must keep PII out of places it doesn't belong (logs, prompts to third-party models where policy forbids it, long-term memory) and enforce guardrails on inputs, outputs and actions.
- Interactive runs should start responding within about 2 seconds, and the platform overhead per step (excluding model and tool time) should stay under 100 ms.
- Cost should be visible and bounded per run, per agent and per team.
Below the line (out of scope)
- Multi-region active-active. We'll run in one region with standard backups.
- Model choice and prompt tuning for individual agents.
Now the arithmetic, because one number dominates.
- 1M runs x 10 model calls = 10M model calls a day, about 115 per second on average and ~350 per second at peak. The control plane is not the hard part.
- Each model call re-sends the whole context. If the stable prefix (system prompt plus tool definitions) is 5k tokens and each step adds ~1k tokens of tool calls and results, step k sends 5k + k·1k tokens. A 10-step run sends about 105k input tokens in total; a 50-step run sends about 1.5M. Input tokens grow roughly with the square of the number of steps.
- At 10M calls averaging 10k input tokens, that's 100B input tokens a day. At an assumed $3 per million input tokens, that's $300k a day before output tokens.
- Providers discount cached prompt prefixes heavily (often 50-90% off for the cached part). If 80% of input tokens hit the cache at a 90% discount, the bill drops to roughly $60k + $24k = $84k a day.
- Traces: ~20 events per run at a few KB each, plus large tool outputs, is on the order of 100-200 GB a day. Easy for object storage plus a columnar index.
The interesting conclusion is that the platform's job is mostly about tokens and trust, not throughput. 350 requests per second is a small service. What decides whether the platform works is how we lay out context so it caches, how we stop runs from growing forever, and how we make sure a model that can be talked into anything can only do safe things.