Which tool errors should an agent retry, and where should the retry logic live: in the model or in the harness? Use a payment tool that times out as your example.
Agents and tools · Intermediate 3
Short answer
Retry only errors that are temporary, such as timeouts and rate limits, and only if the call is safe to repeat. The harness should do those retries in code, with backoff and a limit. Permanent errors go back to the model as a clear message. For a payment, use an idempotency key and check the status before any retry.
Deeper answer
Errors fall into three groups. Temporary ones, such as a timeout or a 429, may succeed if tried again. Input errors, such as a wrong ID format, will fail every time until the arguments change, so the model must see the message and fix its call. Permanent ones, such as insufficient balance, need a different plan or a person.
Retries for temporary errors belong in the harness. Code can apply backoff, count attempts and stay cheap. If the model does it, each attempt costs a full model call and may loop. A timeout is a special case, because you do not know whether the action happened. For a read, just repeat it. For a payment, repeating can charge the customer twice. So the tool takes an idempotency key that stays the same across attempts, and the harness checks the payment status before it tries again. Interviewers listen for the three groups, for idempotency, and for error text written so the model can act on it.
What a strong answer covers
- Separates temporary errors from input errors and permanent errors
- Puts retries for temporary errors in harness code, with backoff and a limit
- Returns clear error messages to the model so it can fix its call or change plan
- Knows a timeout leaves the outcome unknown, so checks status first
- Uses an idempotency key for calls with side effects
Answer it out loud in the mock interview about 2 min
Follow-ups to expect
- What should the model see after the harness has given up on retries?
- How do you make a tool idempotent if the downstream API is not?
- How would you detect an agent that repeats the same failing call?
Common mistakes
- Retrying every error, including ones caused by bad input
- Letting the model retry a payment with no idempotency key
- Hiding errors from the model, so it reports success
Learn it
- What are common failure modes of agents, and how do you guard against them?
- What kinds of memory can an agent have, and how do you implement them?
- Your agent ran overnight and ran up a large API bill. What probably happened, and what do you change?
- How would you design a harness for an agent that has to work on one task for several hours?
- What is the difference between an agent and a workflow?
- Three agents work in parallel on one codebase, keep overwriting each other's changes, and two of them made opposite design decisions. How do you redesign the system?
- Design the sandbox for a data-analysis agent that writes and runs Python on spreadsheets that users upload.
- Your research agent gives good answers but costs about ₹45 and takes three minutes per task, against a target of ₹10 and one minute. Where do you look?
- You need an eval suite for an agent that books and cancels appointments in a real clinic system. How do you build the test environment so that runs are safe and repeatable?
- A finance team asks you for an AI agent to process supplier invoices: read the PDF, extract the fields, match them to the purchase order, and post to the ledger. Would you build an agent?
- Forty minutes into a data-cleaning task, your agent starts breaking a rule the user gave at the start: never delete rows. What is happening, and what do you change?
- How should an agent decide that a task is finished? Use this case: it is asked to update 30 product descriptions, updates 12, and reports that the work is complete.
- Your agent serves one user at a time in the demo, and now 2,000 employees will start tasks that each run for 5 to 20 minutes. How do you run this in production?
- Your company wants its agents to use the internal ticketing system through MCP. How would you design and ship that MCP server?
- Your travel agent plans flight, hotel and cab up front, and when the planned flight is sold out it still books the hotel for the old dates. How should the loop be designed?
- How do you make agent runs reproducible enough to debug, when the model is not deterministic and the tools return live data that changes?
- An agent runs a 12-step employee onboarding task that sends emails and creates accounts, and the worker crashes at step 7. How do you design it so the run can resume without repeating what is already done?
- When a main agent hands a task to a sub-agent, what should go into the hand-off, and what should come back?
- Why does giving an agent more tools often make it worse, and how do you manage an agent that is connected to hundreds of tools?
- How would you design an agent's actions so that most mistakes can be undone, instead of asking a person to approve every step?
- Your assistant saved the note 'prefers calls in Hindi' against the wrong customer and now repeats the mistake in every session. How do you fix it, and how do you stop it from happening again?
- Your support agent has two tools, search_orders and search_tickets, and it often calls the wrong one or passes a phone number where an order ID is needed. How do you fix it?
- What are computer-use or browser agents good for, and what are their risks?
- What is context engineering, and why does it matter for agents?
- An agent completes a task correctly most of the time but sometimes goes badly wrong. How do you debug it?
- What makes a good tool for an agent?
- Design an agent that handles refund requests for an online store.
- You changed your agent's harness. How do you prove the change made it better?
- What are verification gates in an agent harness, and how would you add them to a coding agent?
- How does tool calling work?
- When should an AI agent ask a human for approval before acting?
- Explain state, nodes, edges and checkpoints in LangGraph.
- What are planning and reflection in agents, and when do they help?
- Two coding agents use the same model, but one solves far more of your tasks. Why could that be, and how would you find out?
- Five teams in your company have built agents on four different frameworks, and security reviews, on-call and hiring are getting harder. Would you force one standard, and how would you make the decision stick?
- Overnight your refund agent approved 340 refunds that it should have rejected, worth about ₹6 lakh, before someone noticed in the morning. After it is switched off, how do you decide when and how it may run again?
- Your single-agent claims assistant completes 82% of tasks correctly, and the team proposes a three-month rewrite into six specialised agents to reach 95%. Do you approve it?
- What is an agent harness, and what is harness engineering?
- What is the Model Context Protocol, and why does it matter?
- When is a multi-agent system worth it, and what are the risks?