An AI agent is a system where a model decides what to do next, uses tools, looks at the result and continues until the task is done. A workflow follows steps you wrote in advance, with the model filling in parts. Many useful products are workflows, and that is a good thing: they are cheaper, faster and more predictable.
The agent loop
- The model gets a goal and the available tools.
- It decides on an action (call a tool or answer).
- Your code runs the action and returns the observation.
- The model plans the next step.
- It stops when the goal is met, or when a limit is hit.
This is the same tool-use loop from the Claude API course, run for as many turns as the task needs.
Memory
- Short-term memory: the conversation and recent tool results in the context.
- Long-term memory: facts stored outside the model (a database or vector store) and retrieved when needed.
Planning and decomposition
Complex tasks work better when broken into sub-tasks. The agent can write a plan, execute steps and revise it as results arrive.
When to use an agent
- Use a plain prompt when one call is enough.
- Use a workflow when the steps are known.
- Use an agent when the steps depend on what is found along the way, such as research or debugging.
Failure modes
- Looping or wandering: always set a maximum number of steps and a cost budget.
- Wrong tool or wrong arguments: validate and give clear errors.
- Compounding errors: a small mistake early spoils later steps.
- Overreach: acting beyond what the user wanted. Use approvals for sensitive actions.
Human in the loop
For anything with real-world effects, let a person review the plan or approve key actions.