Agentic AI · Module 33 of 41 · 10 concepts · about 20 min

Designing Agentic Systems

Six complete designs to the same template: a research agent, a customer support agent, a coding agent, a travel planning agent, an enterprise knowledge agent and an autonomous data analysis agent; each with its requirements, architecture, tools, memory, planning, guardrails, evaluation, scaling and failure handling.

At work: The practice a designer needs before the real thing, and the exact shape of the question in a system-design interview: 'design an agent that…'.

A template for designing any agent

What it is

Work through nine headings, in this order:

  • Requirements: what it must do, for whom, at what volume, speed and cost; and what it must never do.
  • Architecture: the simplest shape that meets them: workflow, single agent, or several.
  • Tools: the few task-shaped tools, each marked read or write.
  • Memory: what is kept within a task, and across tasks.
  • Planning: how the work is decomposed and tracked.
  • Guardrails: the worst case, and the code that prevents it.
  • Evaluation: how you will know it works, before and after launch.
  • Scalability: the bottleneck, and the plan for it.
  • Failure handling: what happens when a step, a tool or the model fails.

Why it matters

The order matters.

  • Requirements first, because 'should this be an agent at all?' is answered there.
  • Tools and guardrails before prompts, because they decide what is possible and what is safe.
  • Evaluation before launch, because without it no later change can be trusted.
  • The same template works on a whiteboard in forty minutes and in a design document over a week.

In the real world: A design review uses these nine headings as its agenda; a proposal that cannot fill 'the worst thing it can do, and what stops it' is sent back.

Visual example

Template

Each step constrains the next. Prompts come after all of them.

The order to design in

  1. RequirementsNeeds, volume, cost, 'must never'
  2. ShapeWorkflow, one agent, or several
  3. Tools and guardrailsWhat it can do; what bounds it
  4. Memory and planningWhat it holds; how it works
  5. EvaluationEnvironment, cases, metrics
  6. Scale and failureBottleneck; every way it stops

Starting with the architecture diagram. Without requirements you cannot choose between a workflow and an agent, and without the worst case you cannot place a single guardrail.

Design a research agent

What it is

A user asks an open question ('how are grocery delivery firms handling returns?') and wants a cited report in minutes. Requirements:

  • searches the web and reads many sources;
  • every claim carries a source that supports it;
  • conflicting sources are reported, not smoothed over;
  • finishes within a cost and time budget, and says what it could not find;
  • must never invent a citation or follow instructions found on a web page.

Why it matters

Three decisions define it.

  • Parallel sub-agents: sources are independent, so one sub-agent per sub-question reads and returns a short brief. The lead's context holds briefs, not web pages.
  • Verification as a separate step: a checker confirms each claim appears in its cited source, because the writer will otherwise cite plausibly and wrongly.
  • Untrusted input everywhere: every page is hostile until proven otherwise, so the reading agents have no private data and no tools that act.

In the real world: A market-research product moved from a single loop to a lead with parallel readers and a claim verifier; unsupported citations fell from about one in six to under one in fifty.

Visual example

Design

The same seven headings for every system, so the designs can be compared.

The research agent: design decisions
aspectdecision
Toolssearch, fetch_page (returns extracted text, capped), save_note. All read-only
MemoryA notes store of findings with source links; no cross-user memory needed
PlanningPlan first into sub-questions; dynamic replanning after the first round
GuardrailsResearchers have no private data and no write tools; page text marked as data; domain allow or block lists; cost and step budgets
EvaluationCitation precision (does the source support the claim), coverage against a reference outline, hallucination rate, cost and time per report
ScalabilityFan out to many workers; a queue per report; cache fetched pages; the model's tokens-per-minute quota is the limit
Failure handlingA failed fetch is skipped and recorded; on budget exhaustion, return a partial report that says what is missing
Architecture

question
  -> planner: decompose into 4-8 sub-questions, with a search budget each
  -> researchers in parallel (small model): search, fetch, extract -> brief with sources
  -> lead: find gaps and conflicts -> one more targeted round if needed
  -> writer: draft only from the briefs
  -> verifier: each claim checked against its cited source
  -> report, with conflicts and gaps stated

One agent in one long loop, reading page after page into a single context. By the tenth source it has lost the question. Split the reading from the thinking.

Practise it: Design an Autonomous Research Agent

Design a customer support agent

What it is

Kirana Kart's agent resolves order problems in chat. Requirements:

  • answers policy questions and resolves refunds, cancellations and rescheduling;
  • first response within two seconds; most tasks done in under fifteen;
  • sees only the signed-in customer's data;
  • refunds within policy, capped, with large ones approved by a person;
  • must never refund twice, act on another customer's order, or promise what it has not done.

Why it matters

This is the design where money moves, so the tool layer is the centre.

  • A workflow with one agent step: route, verify, decide and act are fixed stages; the model has freedom inside the investigation stage only.
  • Enforcement in tools: identity from the session, caps and eligibility checked in code against the real order, idempotency keys on every write.
  • A clear path to a human, with a summary, because knowing when to stop is part of resolving.

In the real world: A delivery company's agent resolves about two-thirds of order tickets alone; the rest reach a person with a summary, and the reversal rate, refunds a human had to undo, is the metric the team watches most.

Visual example

Design

The same seven headings for every system, so the designs can be compared.

The customer support agent: design decisions
aspectdecision
Toolsget_order, get_recent_orders, get_policy (read); refund_fee, refund_item, cancel_order, reschedule (write); hand_over
MemoryConversation state checkpointed per ticket; a small customer profile (preferences, allergies); past tickets retrieved on demand
PlanningStep by step within a stage; a to-do list when the message contains several requests
GuardrailsTools bound to the session's customer; caps and eligibility in code; approval above ₹500; three refunds a day; output verified against the action log
EvaluationEnd state of a fake payments table; trajectory rules (looked up before refunding); refusal and manipulation cases; online: resolution, escalation and reversal rates
ScalabilityStateless async workers on a queue; per-tenant limits; small model for routing; prompt caching; provider quota is the ceiling
Failure handlingIdempotent writes; resume from checkpoint; tool timeout leads to one retry then hand-over; never report an action that is not in the ledger
Architecture

message
  -> gateway: authenticate, rate limit, mask card numbers
  -> router (small model): question | order problem | other
  -> question: RAG over the help centre -> grounded answer
  -> order problem: agent loop with get_order, get_policy, refund, cancel, reschedule
       -> policy engine: allow | deny with reason | needs approval
       -> approval pauses the run; state is saved
  -> output check: amounts and claimed actions match the action log
  -> reply, or hand_over with a four-line note

A fully free agent with a refund tool and limits written in the prompt. The first persuasive customer finds the gap. Fix the stages; put every limit in the tool.

Practise it: Design an AI Customer Support Agent

Design a coding agent

What it is

A developer describes a change ('add retry with backoff to the payment client') and the agent makes it in the repository. Requirements:

  • finds the relevant code in a large repository;
  • edits files, runs the tests, and fixes what fails;
  • produces a reviewable change with an explanation;
  • works for minutes to hours, and can be interrupted and resumed;
  • must never push to the main branch, leak secrets, or run destructive commands outside its workspace.

Why it matters

Coding agents work because the feedback is strong, so the design protects that loop.

  • Tests as ground truth: the agent's 'done' is a passing test run, not its own opinion.
  • A sandbox: it runs arbitrary commands, so it works in an isolated copy with no production credentials and restricted network.
  • Context management is the hard part: a repository does not fit in a context, so it searches and reads on demand, keeps a plan file, and compacts its history.

In the real world: A team's coding agent opens pull requests overnight; nothing merges without green tests and a person's review, and a rule blocks any change that edits a test and its code in ways that only make the test weaker.

Visual example

Design

The same seven headings for every system, so the designs can be compared.

The coding agent: design decisions
aspectdecision
Toolssearch_code, read_file, edit_file, run_command (sandboxed), run_tests, git operations limited to its branch
MemoryA plan and notes file in the workspace; repository instructions file (how to build and test); compaction for long sessions
PlanningExplore, then plan, then implement step by step; a to-do list; replanning when tests reveal a wrong assumption
GuardrailsSandbox with restricted network and no secrets; command allow or deny rules; branch-only writes; human review before merge; file contents treated as untrusted
EvaluationHidden tests pass; no unrelated files changed; the build is green; review acceptance rate; time and cost per merged change
ScalabilityOne sandbox per task; many tasks in parallel; long runs checkpointed; sandbox start-up time and test duration are the bottlenecks
Failure handlingA failing test is the next observation; a cap on fix attempts then stop and report; a crashed sandbox resumes from the branch and notes
Architecture

task
  -> sandbox: fresh checkout on a branch, no production credentials
  -> explore: search and read files; write a short plan to a notes file
  -> loop: edit -> run tests / linter / type checker -> read failures -> fix
       -> compaction keeps the plan, changed files, and failing tests
  -> self-review: diff checked against the task and the repository's conventions
  -> pull request with a description -> human review -> merge

Letting the agent decide it is finished. It will declare success with failing tests or, worse, edit the tests to pass. 'Done' is checked by running the real tests it did not write.

Design a travel planning agent

What it is

A user says 'four days in Jaipur in March for two, under ₹40,000' and wants an itinerary they can book. Requirements:

  • searches flights, trains, hotels and activities against dates, budget and preferences;
  • respects hard constraints (budget, dates) and soft ones (prefers mornings, vegetarian);
  • presents options and books only what the user confirms;
  • prices and availability must be current at the moment of booking;
  • must never pay without explicit confirmation of the exact itinerary and total.

Why it matters

It is a planning problem with a payment at the end.

  • Plan with dependencies: dates fix flights; flights fix hotel nights; searches for each are independent and run in parallel.
  • Constraints checked in code: the budget total is arithmetic, not a model's judgement.
  • Stale data is the trap: a price seen in the search may be gone at booking, so every booking re-checks, and a failed leg triggers compensation for those already booked.

In the real world: A travel assistant that held the hotel, failed on the flight and reported 'trip booked' now runs a saga: the hotel hold is released and the user is told plainly which part failed.

Visual example

Design

The same seven headings for every system, so the designs can be compared.

The travel planning agent: design decisions
aspectdecision
Toolssearch_flights, search_trains, search_hotels, search_activities, get_weather (read); hold, pay, confirm, cancel (write)
MemoryTrip state (the chosen itinerary and holds) checkpointed; long-term preferences such as seat, diet and budget habits
PlanningPlan first with a dependency graph; parallel waves; replanning of only the affected legs
GuardrailsBudget and date constraints verified in code; signed user confirmation of the exact itinerary; spend cap; payment details never in the context
EvaluationConstraint satisfaction rate; itinerary validity (no overlaps, feasible transfers); booking success; user edits needed; time to first itinerary
ScalabilitySupplier API rate limits are the bottleneck: cache searches briefly, batch, and limit concurrency per supplier
Failure handlingRe-check price and availability at booking; on a failed leg, compensate held legs and offer alternatives; never leave a half-booked trip unreported
Architecture

request
  -> clarify: ask for anything essential that is missing (dates, origin)
  -> planner: subtasks with dependencies
  -> parallel search: transport | hotels | activities | weather
  -> assemble 2-3 itineraries; code checks budget and timing constraints
  -> user chooses and edits; replanning touches only what changed
  -> confirmation card: exact items and total, signed
  -> booking saga: hold -> pay -> confirm, with an undo for each step

Booking from the search results. Minutes have passed and the fare has changed. Search to propose; re-quote to book; and confirm the re-quoted total with the user.

Practise it: Design a Multi-Agent AI System, Design an Autonomous Research Agent

Design an enterprise knowledge agent

What it is

Employees ask questions across the company's wikis, documents, tickets and chat. Requirements:

  • answers from internal sources with citations;
  • each employee sees only what they are permitted to see in the source systems;
  • handles questions that span several systems;
  • says when it does not know, and when sources disagree or are out of date;
  • must never reveal a document to someone without access to it.

Why it matters

The hard part is permissions, not retrieval.

  • Access control at retrieval time: every search is filtered by the asking employee's rights, enforced in the store, never by the model.
  • Agentic retrieval: source selection, query rewriting, multi-hop look-ups and a support check, because enterprise questions rarely live in one document.
  • Freshness and ownership: every answer shows its sources and their dates, so a wrong one can be traced to a stale page and fixed at the source.

In the real world: A company's assistant was withdrawn after an intern asked about 'reorganisation plans' and got a summary of a board document; the relaunch enforces source permissions in every index query and tests that boundary on every release.

Visual example

Design

The same seven headings for every system, so the designs can be compared.

The enterprise knowledge agent: design decisions
aspectdecision
ToolsOne search tool per source, each taking the user's token; get_document; who_owns (to route follow-ups). All read-only
MemoryConversation history per session; no cross-employee memory; indexes kept in sync with source permissions
PlanningRetrieval planning for multi-part questions; iterative retrieval capped at three rounds
GuardrailsPermission filter in every index query; documents treated as untrusted text; no outbound tools; sensitive categories (HR, legal) on stricter paths
EvaluationRetrieval recall on a labelled set; groundedness and citation accuracy; a permission test that one user never sees another's document; 'no answer' correctness
ScalabilityIndex freshness and permission sync are the heavy jobs; per-tenant indexes; cache embeddings; small model for routing and grading
Failure handlingA source being down is reported, not hidden; conflicting sources are shown side by side; a failed support check yields no answer
Architecture

question (with the employee's identity)
  -> router: which sources? wiki | docs | tickets | HR | code
  -> rewrite the query; search each source WITH the employee's access filter
  -> grade passages; search again if insufficient (bounded)
  -> answer only from passages; cite each claim
  -> support check; 'I couldn't find this' when it fails
  -> answer with sources, dates and owners

Indexing everything into one store and filtering results after retrieval, or asking the model to respect permissions. A restricted document's content has then already been read. Filter inside the query.

Design an autonomous data analysis agent

What it is

An analyst asks 'why did orders drop last week?' and the agent investigates the data warehouse. Requirements:

  • finds the right tables, writes and runs queries, and analyses results with code;
  • produces charts and a written explanation with the queries shown;
  • respects each user's data access;
  • results are reproducible: the same question and data give the same numbers;
  • must never modify data, run unbounded queries, or present a guess as a finding.

Why it matters

It writes and runs code against real data, so containment and verifiability come first.

  • Read-only by construction: a read-only database role with row-level security, and a sandbox for Python with no network.
  • Schema retrieval: a warehouse has thousands of tables; the agent searches a catalogue of table descriptions instead of being shown them all.
  • Show the work: every number in the answer traces to a query that can be re-run, because a plausible wrong number is the main risk.

In the real world: An analytics assistant once explained a 'drop' that was really a duplicated join; it now reconciles every aggregate against a known total and shows the queries, and analysts catch the rare slip in review.

Visual example

Design

The same seven headings for every system, so the designs can be compared.

The autonomous data analysis agent: design decisions
aspectdecision
Toolssearch_schema, get_metric_definition, run_sql (read-only), run_python (sandboxed), make_chart
MemoryAnalysis state (queries run, results as stored artifacts, hypotheses) checkpointed; saved metric definitions as shared procedural memory
PlanningHypothesis-driven plan, revised as results arrive; a to-do list of checks
GuardrailsRead-only role and row-level security; query cost and row limits; sandbox with no network or credentials; approval for costly queries; results labelled finding or hypothesis
EvaluationAnswer correctness on questions with known answers; SQL validity and efficiency; reproducibility across runs; whether stated numbers match query output
ScalabilityWarehouse concurrency and query cost are the bottlenecks: queue queries, cache results, sample large tables first
Failure handlingA failing query's error is the next observation; cap repair attempts; if the data cannot answer the question, say so with what was tried
Architecture

question
  -> find tables: search the schema catalogue and metric definitions
  -> plan the analysis: hypotheses to test, in order
  -> loop: write SQL -> validate (single SELECT, row and cost limits) -> run as the user
       -> analyse in a Python sandbox -> chart
       -> sanity checks: row counts, totals reconcile, no silent fan-out
  -> human gate before expensive queries
  -> report: finding, evidence, queries, caveats

Returning a confident narrative without the queries. Nobody can check it, and a join that silently duplicated rows produces a figure that is wrong and convincing. The queries and the reconciliation checks are part of the answer.

The six designs compared

What it is

The same questions asked of all six systems. Reading across a row shows how one concern is solved differently; reading down a column gives one system's character at a glance.

Why it matters

Comparison turns six examples into a method.

  • The shape follows the task's structure: independent strands fan out, money moves through fixed stages, exploration uses a loop.
  • The 'must never' decides the main guardrail in every case.
  • The check on success is always something outside the model: tests, a ledger, a source, a query.
  • In an interview, the fastest route to a good answer is to say which of these six the new problem most resembles, and what differs.

In the real world: A candidate asked to design a legal-contract review agent says 'this is the research agent's shape with the knowledge agent's permissions', and has the outline of an answer in one sentence.

Visual example

Comparison

The last column is what makes each one trustworthy.

Six agents, five questions
agentshapemain riskmain guardrailsuccess is checked by
ResearchLead with parallel readersInvented or unsupported claimsReaders have no private data or write toolsEach claim found in its source
Customer supportWorkflow with one agent stageWrong or repeated refundsCaps and identity in tools; approvalThe payment ledger
CodingSingle agent in a sandboxDestructive commands; fake successSandbox; human review before mergeTests it did not write
Travel planningPlanner with parallel search, then a sagaPaying for the wrong or stale itinerarySigned confirmation; re-quote at bookingConstraint checks in code
Enterprise knowledgeAgentic RAGShowing a document to the wrong personPermission filter inside every queryCitations and a support check
Data analysisSingle agent with SQL and a sandboxA plausible wrong numberRead-only role; sandbox; query limitsRe-runnable queries; reconciliation

Interview questions: designing agentic systems

What it is

The questions interviewers ask about designing agentic systems, from the first screening call to the senior round. Cover the answer, say yours aloud, then compare.

Why it matters

Reading an idea and explaining it are different skills.

  • Each answer below is the two or three sentences an interviewer is listening for.
  • The reasoning behind each one is in the cards above. If an answer surprises you, go back to that card.

In the real world: The designs that score highest are not the most elaborate; they are the ones where the candidate names the worst outcome in the first two minutes and can point to the box that prevents it.

Q: How do you approach an agent design question?

Requirements and the 'must never' first; then the simplest shape; then tools marked read or write and the guardrails in code; then memory and planning; evaluation; scale; and failure handling. Prompts come last.

Q: Design a customer support agent that can issue refunds.

A workflow of route, verify, decide and act, with the model free only inside investigation. Tools bound to the session's customer, eligibility and caps checked in code, idempotency keys, approval above a threshold, output verified against the action ledger, and a hand-over path. Evaluate on the end state of a fake payments system.

Q: Design a research agent.

A planner decomposes the question; parallel readers with search and fetch return short sourced briefs; the lead fills gaps; a writer drafts from briefs only; a verifier checks every claim against its source. Readers hold no private data and no write tools. Budgets bound cost; partial results are reported honestly.

Q: Design a coding agent.

A sandboxed checkout on a branch; explore, plan, then an edit-and-test loop where failing tests are the feedback; compaction and a notes file for long runs; branch-only writes and human review before merge. Success is hidden tests passing with no unrelated changes.

Q: Design a travel planning agent.

Clarify, plan with dependencies, search in parallel, check constraints in code, present options, take a signed confirmation of the exact itinerary, then book as a saga that re-quotes each leg and compensates on failure.

Q: Design an enterprise knowledge agent.

Agentic RAG with source routing, query rewriting, bounded iterative retrieval and a support check, where every index query is filtered by the asking user's permissions in the store. Answers cite sources with dates. Test the permission boundary explicitly.

Q: Design a data analysis agent.

Schema retrieval, a hypothesis-driven plan, SQL validated and run under a read-only role with row-level security and cost limits, analysis in a network-less sandbox, reconciliation checks, and a report that includes the queries.

Q: What do all good agent designs share?

The simplest shape that fits, few task-shaped tools, limits enforced in code, a success check outside the model, saved state with idempotent writes, an evaluation set with adversarial cases, and a path to a human.

Beginning with 'I would use a multi-agent system with…' before a single requirement has been stated.

Exercise: design a seventh agent

What it is

A short build that uses this module's ideas. Write it yourself before looking anything up; the checks at the end tell you whether it works.

Why it matters

An idea you have only read fades in a week.

  • Building it once, even in fifty lines, is what makes it yours.
  • Interviewers can tell the difference between someone who has read about a loop and someone who has debugged one.

In the real world: A hiring loop gives candidates exactly this as a take-home; the two-page limit is deliberate, since the skill being tested is deciding what matters.

Your task. Design an agent for a domain not covered here, to the nine-heading template, on two pages.

Steps

  1. Choose one: a recruiting screener, an invoice processor, an IT help-desk agent, a contract reviewer, or a clinic appointment agent.
  2. Write five requirements and three 'must never' statements.
  3. Decide the shape and justify it in two sentences. State which of the six designs it most resembles and what differs.
  4. List the tools with read or write, and for each write tool the rule that bounds it and where that rule is enforced.
  5. Fill in memory, planning, evaluation, scalability and failure handling, one or two lines each.
  6. Draw the architecture as a text diagram of seven lines or fewer.
  7. Write three evaluation cases: one common, one that should be refused, one adversarial, each with its end-state check.

You are done when

  • Every 'must never' maps to a specific control enforced in code, not in a prompt.
  • Success is checked by something outside the model.
  • A colleague can find the bottleneck and the hand-over path in under a minute.
  • The whole design fits on two pages.

Stretch. Have a colleague attack your design for fifteen minutes with the threats from module 32 and revise it.