Shaf Lab

AI agents

Programs that use a language model to plan and take actions with tools.

An AI agent is a program that uses a language model to plan and take actions with tools, instead of only answering a single prompt. It might search a repo, call an API, edit a file, or ask you a question, then continue until it reaches a goal or a stop condition. The model chooses the next step; your code supplies the tools, the limits, and the memory.

It helps to separate agents from workflows. In a workflow, your code decides the sequence of steps and the model fills in individual steps. In an agent, the model chooses the sequence itself in a loop: plan, act with a tool, observe the result, and repeat. Agents handle open-ended tasks better, but mistakes compound over many steps, so prefer a workflow whenever you can write the steps down in advance.

A useful distinction is a framework agent versus a product agent. A framework agent is a flexible loop you drive from a chat or a script. A product agent is built for one job, with a fixed set of tools and a clear success condition. The first is good for exploration. The second is what you ship, because you can test it, budget it, and explain what it is allowed to do.

Give every agent a narrow tool list and a hard stop: a step budget, a time limit, or a required approval for risky actions. An agent that can do anything will eventually do something you did not intend. Logs and traces should make those limits visible when you inspect a run.

If you do not need a loop, you do not need an agent. A single model call with retrieved context is often enough. Reach for an agent when the task has several steps and the next action depends on what just happened.

ReAct (agent pattern)

An agent pattern that alternates short reasoning steps with tool actions and their observed results.

ReAct, short for reason and act, is an agent pattern that interleaves brief reasoning with tool actions. The model writes a thought about what to do next, takes an action by calling a tool, reads the observation that comes back, and repeats until it can answer. Each step responds to what the last tool actually returned rather than to a plan made up front.

The pattern was described in a 2022 research paper and became the basic shape of most agent loops, even where the explicit thought text is now hidden or replaced by native tool calling and built-in reasoning. Its weakness is drift on long tasks, so production agents add step budgets, explicit plans, and checks between steps.

Human-in-the-loop

A checkpoint where a person must approve or correct an AI system's work before it continues.

Human-in-the-loop means building points into an AI system where a person must approve, edit, or reject its work before it continues. In agents, approval is typically required before actions that are hard to undo or visible to others, such as sending messages, spending money, deleting data, deploying code, or changing permissions.

Good checkpoints are specific and few. Show the person exactly what will happen, such as the draft email, the diff, or the payment amount, and make approval quick, so it does not become rubber-stamping. Place checkpoints by risk rather than everywhere, and record each decision in the trace so you can see what was approved and by whom.