The interview problem
An agent alternates between searching and reopening the same documents. Design termination controls that bound cost while still allowing useful retries.
Original practice, not a reported company interview. All worked numbers are illustrative. Interview date: not applicable. Written October 3, 2026.
1. Scope and assumptions
Assume a durable workflow and tools with variable latency. Define progress through observable task artifacts rather than the model saying it is making progress. Some legitimate actions repeat, so duplicate text alone is not a termination proof.
2. Architecture and decisions
Step proposal → reserve budget → execute → record evidence → evaluate progress → continue or stop
Persist separate budgets for tool calls, generated tokens, wall time and outstanding work. Reserve budget atomically before dispatch so parallel branches cannot overspend a shared allowance. Record normalized action fingerprints and result versions; repeated reads of unchanged content provide no new evidence, while a changed version may justify another step.
Track milestones such as a new relevant source or a verified artifact. After a bounded interval without a milestone, require a changed plan or stop with a partial result explaining what remains unresolved. Distinguish retryable transport failures from a successful tool call that simply did not help. Cancellation must propagate to workers; spending already in flight remains part of the final accounting.
3. Work through the example
With a 40-call limit, 28 completed calls and 6 reserved calls leave 6 available reservations, not 12. If four branches each request two calls, admit at most three such reservations. A separate 120-second deadline may stop the workflow before it exhausts its call count.
4. Failure cases and trade-offs
An agent can manufacture trivial milestones unless acceptance is tied to task evidence. Overaggressive cycle detection breaks pagination and polling. Unlimited retries hidden inside a tool defeat the outer budget, so propagate deadlines and retry limits. A conservative stop protects cost at the price of incomplete tasks; expose resumable state rather than claiming completion.
5. Validation and acceptance
Replay cycles of length two and three, repeated transient failures, slow cancellation and concurrent reservations. Assert no new dispatch after the terminal state. Track useful artifact yield per call along with termination reasons, rather than optimizing for fewer steps alone.
6. Follow-ups and self-review
When can a human extend a stopped task budget safely? Reward explicit reservation accounting, observable progress, bounded internal retries and honest partial outcomes.
Sources and related practice
AWS Step Functions documents workflow timeout behavior; the multi-budget progress controller here is original.
Read the primary technical reference
Reference retrieved October 3, 2026. Retrieval date is not an interview or source publication date. The reference supports the named concept; scenario, architecture, examples and rubric are original.
Continue with Resume long-running business workflows; Design an agent evaluation platform.
Continue your preparation
Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.