Cost control Interview Questions
3 curated cost control interview questions with detailed answers and examples.
← Browse all interview questionsMultiple agents pay off when a task splits into independent pieces that can run in parallel, each needing its own large context, such as broad research across many sources. They are a poor fit when the pieces depend on each other or must share the same decisions, like most UI and coding tasks, because subagents lose context and make conflicting choices. Default to one agent with good tools, and split only when you have measured that one context window or one sequential loop is the bottleneck.
An agent loop keeps calling the model, running the tools it asks for and feeding results back. It stops naturally when the model finishes without requesting a tool, when it calls a tool that has no server-side execute (so the client or a human must act), or when a call needs approval. On top of that you add hard limits: a maximum step count, a stop-on-specific-tool rule, and custom conditions such as a token budget, because the model deciding to stop is not a guarantee.
Limit in layers, inside the Route Handler and before the model call. Identify the caller by user id (IP only as a fallback), apply a request limit such as a sliding window in Redis, and add a daily token budget per user because one request can cost far more than another. Cap input size and maxOutputTokens, return 429 with a Retry-After header when a limit is hit, and show a calm message in the UI.