Tool Calling & Agents · 3 to 4 hours
Design an agent with idempotent side effects
Design an agent that closes a ticket and sends one approved closure email safely across duplicate jobs, crashes, timeouts, and concurrent workers, and say exactly what the design can and cannot guarantee.
4 h
Used in interview rounds:
AI System Design (Hard)Overview
Design an agent executor that performs authorized side effects safely across retries, crashes, duplicate messages, and uncertain external outcomes. A strong answer defines durable state, logical operation identity, approval boundaries, reconciliation, and explicit limits on what execution can guarantee.
Study time: 3 to 4 hours
Interview format: System design discussion with a failure timeline
By the end you can
- Separate the model's proposals from the executor's authority over side effects
- Distinguish run, tool-call, and logical operation identifiers, and key idempotency on accepted intent
- Make a local mutation idempotent inside one transaction, and handle external effects whose outcome is unknown
- Bind approvals to the exact recipient, content, and resource version, and revalidate them at execution
- Resume after a crash from durable state, and test duplicates, crashes, leases, and replay windows
Prerequisites
Helpful background: Familiarity with transactions, queues, and distributed systems helps.
This topic covers workflows versus agents, typed tools, approval boundaries, state, and termination. Specific frameworks and protocols appear as tags.
In this guide
- Separate planning from authority
- Distinguish three identifiers
- Model durable operation state
- Idempotency within one transactional store
- External services and unknown outcomes
- Worked scenario: close a ticket and send one email
- Failure timeline
- Bind approvals to concrete effects
- Concurrency and stale state
- Durable agent state and resumption
- Budgets, termination, and compensation
- Evaluation and fault injection
Hard questions are part of Premium: the study guide, reference answer, rubric, and exercises unlock with Premium.
Related on CodeSnatch
Lessons, problems, and articles that build the skills this question uses.
System Design
Compares two-phase commit and sagas for work that spans a database and another service, with idempotent steps and compensations.
Community article
Walks through idempotency key bugs that real APIs ship: concurrent retries, a response lost after the work, and key lifetime.
System Design
Its sections on leases and split brain help when reasoning about several workers that each believe they own a job.
AI Engineering
Binds an approval to the exact reviewed artifact and revision and rechecks it at publication, a parallel approval problem.
AI Engineering
Debug a webhook handler where redeliveries and timed-out sends led to duplicate texts, a next step after this design.
Practice the interview question
Answer it in your own words before you look at the reference answer.
