Agent Control
Constraint is the skill. Autonomy is a budget.
An LLM plus tools in a loop with no bounds is how teams discover four-figure bills and unexplainable behaviour in the same week. The engineering is in the constraints: what it may touch, how far it may go, what it does when it is stuck.
What you learn
- Tool scoping and least-privilege capability design
- Explicit state machines versus "let the model decide"
- Hop budgets, cost budgets, dedup, and supervisor patterns
- Escalation paths and graceful degradation when the agent cannot finish
- Framework-agnostic judgement: graphs help, but control of state and tools is primary
Tools you will actually touch
The assignment pack
A support-triage agent handles inbound tickets. It must resolve what it can, escalate what it cannot, never spend more than a fixed amount per ticket, and never loop. Build it so its worst day costs a known number.
- Explicit state machine with named states and legal transitions
- Per-run hop budget and cost budget, both enforced in code, not in the prompt
- Dedup so the same tool call is not repeated in a loop
- Escalation path with a human handoff that carries context
- A cost report showing worst-case and median spend per run
A while loop with tools. Budget is a hope, and the state lives in the conversation.
Bounded hops and cost, explicit state, working escalation, measured spend.
Supervisor catches pathological runs, degradation is graceful, and the cost model is validated against real traffic.
The tutorial pack
Bound a runaway agent
- 1Build the naive loop deliberately: LLM + tools + while True
- 2Run it on an ambiguous task and watch it loop
- 3Add token and hop accounting; make the budget visible per run
- 4Refactor to an explicit state machine with legal transitions
- 5Add dedup and a supervisor that kills pathological runs
- 6Add the escalation path and test the human handoff
Let the unbounded version run until it burns its budget on a task it cannot complete. Read the trace and count exactly where the money went. That trace is the argument for every constraint you add next.
- Worst-case and median cost per run
- Hop distribution, and how many runs hit the ceiling
- Escalation rate and whether escalations carried enough context to be useful
You must be able to answer
AI use is mandatory on every assignment. The integrity mechanism is defend-your-work, so these are the questions that decide whether the work counts.
- “What is the maximum your agent can spend on one bad input, and how do you know?”
- “Where does your state actually live, and what happens if the process dies mid-run?”
- “Which tool would do the most damage if the model called it wrongly, and what stops it?”
- “Why this control structure rather than more autonomy?”
Want to be walked through this phase?
The packs are delivered with live teaching, reviewed assignments, and a defence.
Train with me