AI Foundations 7 - Agents and Autonomous Loops

One tool call answers one question. An agent chains many of them together: decide what to do, do it, look at what happened, decide again. It keeps cycling through that loop until the task looks done, or until something stops it.

Planning

Before diving into a large task, an agent can lay out a rough sequence of steps first rather than acting on the very first idea that comes to mind. That plan isn’t fixed — new information from an earlier step can send it back to revise later steps, sometimes more than once.

State across steps

Whatever a tool returns at one step gets folded into the context feeding the next decision. That’s how the agent “remembers” what it already tried. It’s also where things get expensive: a long-running loop keeps accumulating context, and eventually that pile of history bumps into the same token and context-window limits covered earlier.

Stopping conditions

A loop needs a defined way to end — task solved, a clear failure it can’t recover from, a step limit, or a timeout. Skip that, and an agent can happily keep looping past the point where it stopped making progress, burning time and tokens on nothing.

Failure modes

A few patterns show up often enough to watch for: retrying the same failing move over and over without noticing it hasn’t worked; wandering away from the original goal over a long sequence of steps; and declaring victory on a task that isn’t actually finished.

Human oversight

Not every step needs a rubber stamp, but risky or irreversible ones — deleting data, pushing to production, sending a message on someone’s behalf — often deserve a checkpoint where a person reviews before the agent continues. Full autonomy is faster. It’s also less forgiving when something goes sideways.

Subagents and delegation

A large task doesn’t have to run through a single agent carrying everything in one context. Splitting it across several narrower agents — each handling one piece, each with its own smaller context — can keep any single agent from drowning in irrelevant history, at the cost of some coordination overhead between them.


Previous: AI Foundations 6 - Prompting and Evaluation