FREE LLMs & agents LESSON · LLMs & agents

Engineer the agent loop

State, tools, authority, and evaluation

An agent is a controlled state machine around a model.

The model proposes an action from an observation. Policy checks whether that action is allowed. A typed tool executes against explicit state. The system records the result, verifies the postcondition, and decides whether to continue. Reliability comes from narrowing each boundary: schemas, budgets, idempotency keys, approvals, sandboxing, and terminal conditions.

The model may choose among allowed actions; it should not define what “allowed” means.

Success is a trajectory, not a pretty final answer.

Agent evaluation must inspect task completion, state changes, unnecessary steps, tool errors, policy violations, cost, latency, and recovery from misleading observations. A final response can sound correct while the wrong record was modified. Build scenario sets with initial state, permitted actions, expected postconditions, and adversarial variants.

Grade the world after the agent acted, not only the words it returned.
Practise this lesson free →