An AI agent is a language model that can take actions — search, call APIs, run code — and decide what to do next based on the results.
The Tool-Use Loop
- You describe available tools to the model: name, description and input schema.
- The model either answers or requests a tool call with arguments.
- Your code runs the tool and returns the result to the model.
- The loop repeats until the model produces a final answer.
The model never executes anything itself; your code stays in control.
Workflows Versus Agents
- Workflows: your code fixes the steps and the LLM fills them in. Predictable, testable and cheaper.
- Agents: the model chooses the steps. Flexible, but less predictable and more expensive per task.
Start with the simplest design. Many problems described as needing an agent are better solved with a single call or a fixed workflow.
When Agents Fit
Open-ended tasks where the path can't be known in advance — research, debugging, multi-step data gathering — especially when the agent can check its own progress (tests pass, searches return results).
Designing Good Tools
Clear names and descriptions, well-documented inputs, concise outputs, and actionable error messages. Most agent failures are tool-design failures.
Safety
Limit permissions, cap steps and spending, sandbox code execution, require human approval for irreversible actions, and treat anything the agent reads as untrusted data — it may contain instructions designed to hijack it.