LEARN. PRACTICE. EXPLAIN.
Learning paths & interview practiceP
← Build a tenant-safe MCP tool server & eval runner
BUILD → VERIFY → EXPLAIN · STEP 4 OF 6

Bound agentic loops and token budgets

Halt terminal errors, repeated identical tool failures, and runaway costs.

UNDERSTAND

Bring these concepts with you

BUILD

Your implementation

  1. Implement runBoundedAgentLoop(stepFn, { maxSteps, maxTokens }).
  2. Halt immediately with 'halted-terminal' on outcome.terminal === true.
  3. Detect repeated identical failing tool+args calls ('halted-loop') and cumulative token overflow ('budget-exceeded').
export function runBoundedAgentLoop(stepFn, { maxSteps = 5, maxTokens = 2000 } = {}) {
  // Orchestrate bounded steps, terminal halts, loop detection, and token budgets.
}
Need a hint?
  • Hash or serialize tool + args cleanly to recognize repeated stuck calls.
  • Track cumulative tokens before allowing the next loop turn.

Saved on this device · 0 / 6000 · Do not include passwords or private data.

VERIFY

Acceptance checks

From the folder containing your downloaded files, run:

node checks.mjs ./starter.mjs 4

This runs checks up to this step. Earlier steps must work first. Mark each result only after checking your implementation; the website does not run or grade it.

Record your attempt to enable the checklist and reference comparison.

Compare with the reference

Attempt the step first, then compare decisions and behavior. There can be more than one correct implementation.

EXPLAIN

Your interviewer asks

Why does increasing the retry budget make an unproductive agentic loop worse?

Say your answer aloud, then record the trade-offs and evidence in your notes above.

LOCAL VOICE REHEARSAL

Rehearse your step walkthrough aloud

Target pacing: 02:00 · Stays in this browser only; never uploaded.

00:00/ 02:00
AlifBay Prep