Your agent ran overnight and ran up a large API bill. What probably happened, and what do you change?
Agents and tools · Pro 1
Short answer
Most likely it got stuck in a loop: retrying a failing tool, re-planning, or calling itself with ever-growing context. I would read the trace to find the loop, then add hard limits: maximum steps and spend per run, a daily budget with alerts, detection of repeated identical calls, and a kill switch. Then add a test that reproduces it.
Deeper answer
Agents fail expensively because each step adds tokens, and a loop multiplies them. Common causes are a tool that keeps returning an error the agent tries to fix by calling it again, a goal it cannot reach so it never decides it is done, or memory that keeps the whole history so each call is larger than the last.
The fix is layered. Per-run caps on steps, tokens and money stop one task; a budget at the account or gateway level stops many; alerts tell a person early. Logging every step with its cost lets you find the cause, and a regression test keeps it from coming back.
What a strong answer covers
- Names likely causes such as loops, retries or growing context
- Reads the trace or logs to find the cause
- Adds per-run step and spend limits
- Adds alerts and a kill switch
- Adds a test so it does not return
Answer it out loud in the mock interview about 1.5 min
Follow-ups to expect
- How would you set the step and spend limits?
- What should the agent do when it hits a limit?
Common mistakes
- Only raising the provider's spending cap
- Fixing the one bug without adding limits
Learn it
Loop limits, budgets and kill switches
- 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?
- 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?
- 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?
- 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?