I keep hearing about “agentic” workflows where an AI step reasons, calls tools, and keeps going until it’s done. How do I build one of these in 3B? I’m curious how the loop actually works, how the AI decides what to do next, and how it knows when to stop.
Great question, and agentic workflows are genuinely one of the more fun things to build once the loop clicks.
Here’s the core idea: an agent isn’t a single AI call, it’s an AI step that calls itself in a loop. Each pass, the model looks at everything that’s happened so far and decides on one of two things: call a tool, or declare it’s done. That self-loop is the engine. A one-shot AI call answers once and stops; an agent keeps coming back around until the work is actually finished.
Here’s how a single turn of the loop works.
The model gets the current state: the original goal, the tools it’s allowed to use, and the transcript of everything so far, including the results of any tools it already called. It reasons over that and produces one of two outcomes. Either it emits a tool call (“look up this IP,” “search these records”), or it produces a final answer with no tool call. If it called a tool, you run that tool, append the result to the transcript, and loop back into the AI step with the updated state. If it produced a final answer, you exit the loop.
So the “deciding what to do next” part is really the model choosing which tool fits the current situation, given the goal and what it’s learned so far. That’s why well-scoped tools matter so much: clear names, sharp single-purpose jobs, strict input schemas, and structured output. The better the model can tell what each tool is for and read what came back, the better its next decision.
The “knowing when to stop” part is the model choosing to respond without a tool call. When it judges the goal is met, it just answers instead of reaching for another tool, and that’s your exit signal. You’ll want a couple of guardrails around that too: a max-iterations cap so a confused agent can’t loop forever, and clean handling of tool errors returned as data so a failure becomes just another thing the model reasons about rather than a dead stop.
The piece that makes it all hang together is the transcript. It’s persisted state you append to each pass: goal, tool calls, tool results, over and over. That growing record is both the model’s memory and the thing that lets each turn build on the last instead of starting cold. It’s also a natural fit for prompt caching, since the stable front of that transcript gets re-sent every turn.
Short version: an agent is an AI step that loops back on itself, deciding each pass whether to call a tool or finish. It picks tools based on the goal and the transcript so far, it stops when it answers without calling a tool, and you bound it with a max-iteration cap and errors-as-data so it stays in control.