Domain 1 · Agentic Architecture

Loop control & guardrails

A free-running loop is a budget bonfire waiting to happen. The difference between a demo and a production agent is the set of guardrails around the loop: hard limits, human checkpoints, and input/output validation. Tune the dials below and watch an agent run safely — or spiral.

max turnstoken budget human-in-the-loopstop conditions output validation
Explain like I'm 10
Picture a toy car that drives itself around a table. Without a fence it'll happily zoom right off the edge. Guardrails are the fences: "stop after 20 laps" (max turns), "stop when the battery's half gone" (budget), and "ask a grown-up before crossing the road" (human approval for risky moves). The car still drives itself — it just can't hurt itself or anyone else.

Drive the agent — with and without rails

Below, an autonomous agent is chewing through a task. Each turn costs tokens and might be a wasted retry. Set the guardrails and run it. Watch which stop condition fires first — a successful finish, a hard limit, or a budget cap. The goal of Domain 1 isn't to make agents that never stop; it's to guarantee they always stop, for a reason you chose.

The guardrail toolkit

GuardrailStops…Layer
Max turns / stepsinfinite loops where the model keeps "almost" finishing.harness
Token / cost budgeta correct-but-expensive run that quietly burns $$$.harness
Human-in-the-loopirreversible actions (refunds, deletes, emails) going out unreviewed.before the tool runs
Input guardrailprompt injection / off-topic / unsafe requests entering the loop.before the model turn
Output guardrailunsafe, off-policy, or malformed answers reaching the user.after the model turn
Tool allow-list / scopingthe agent reaching tools it shouldn't have for this task.tool layer
Exam trap: "the model decides when to stop" is not a stop condition — it's the thing you're guarding against. A reliable agent has at least one external cap (turns and/or budget) the model cannot talk its way past, plus human approval on consequential, irreversible actions. "Add retries" is also a trap if the retry has no ceiling — bounded retries only.
Takeaways: every loop needs an external stop the model can't override — max turns and a token/cost budget. Put a human checkpoint before irreversible actions. Add input and output guardrails around the loop, and scope tools to the task. The model finishing on its own is the happy path, not the safety net.

Curated companion: Anthropic — Building Effective Agents (stop conditions & human oversight).