AI Agents
AI agents are autonomous systems built on top of LLMs that can plan and execute multi-step tasks. Unlike simple chatbots that respond to individual messages, agents can break down complex goals into subtasks, use tools, and iterate until the task is complete.
An AI agent typically has several components: a language model for reasoning, a set of tools it can call (APIs, databases, code execution), a memory system for maintaining context, and a planning loop that decides what action to take next.
Popular frameworks for building agents include LangChain, LlamaIndex, CrewAI, and AutoGen. These provide abstractions for tool calling, memory management, and agent orchestration.
Use cases include customer support automation, code generation pipelines, research assistants, data analysis workflows, and DevOps automation. Key challenges include cost management (agents can make many LLM calls), reliability (handling tool failures gracefully), and safety (preventing unintended actions).
How it works
An AI agent runs a language model in a loop: the model decides on an action, usually a tool call, the application runs it, the result goes back into the context, and the model decides what to do next until the task is done or a limit is hit. Anthropic's guide describes the building block as an "augmented LLM", a model enhanced with retrieval, tools and memory.
The same guide separates two designs. Workflows are "systems where LLMs and tools are orchestrated through predefined code paths"; agents are "systems where LLMs dynamically direct their own processes and tool usage". Many useful systems are workflows, where the code, not the model, decides the order of steps.
The ReAct paper (Yao et al.) showed why interleaving reasoning and acting helps: reasoning traces help the model plan and handle exceptions, while actions fetch new information. Prompted with only one or two examples, ReAct beat imitation and reinforcement learning methods by 34 and 10 percentage points of absolute success rate on the ALFWorld and WebShop benchmarks.
Autonomy has a cost. Anthropic notes that agents' autonomy "means higher costs, and the potential for compounding errors", and suggests finding the simplest solution possible, often a single well-prompted model call with retrieval, before adding an agent loop. Agents fit open-ended tasks where the number of steps cannot be predicted.
Example
The core agent loop in Python-style pseudocode. llm and run_tool stand in for a model client and the application's tool handlers.
messages = [{"role": "user", "content": "Find last week's failed payments and email each customer."}]
for step in range(10): # hard cap on iterations
reply = llm.generate(messages, tools=TOOLS)
messages.append(reply)
if not reply.tool_calls: # no tool requested: the model is done
break
for call in reply.tool_calls:
result = run_tool(call.name, call.arguments) # the application executes it
messages.append({"role": "tool", "id": call.id, "content": result}) The model chooses the steps, such as querying payments, then sending each email, but every action is executed by application code that can validate arguments, require approval for risky actions and log what happened. The step cap stops a confused agent from looping and running up cost.
Common confusion
What is the difference between an AI agent and a chatbot?
A chatbot replies to each message. An agent takes actions through tools across several steps and decides for itself which step comes next. A chatbot can call tools without being an agent if the code, rather than the model, controls the sequence.
Is every multi-step LLM pipeline an agent?
Not in Anthropic's terms. A fixed chain of model calls, or a router that sends requests to set handlers, is a workflow. It becomes an agent when the model dynamically chooses its own steps and tool use.
Related tools & demos
- Agent Engineering Patterns Planning, tools, memory and control flow in more depth.
- AI Agent Cost Simulator Estimate what multi-step agent runs cost per month.
- AI Security Cheatsheet Prompt injection risks that grow once an agent can act.
- Function Calling The mechanism agents use to take actions.
Further reading
- Building effective agents Anthropic, December 2024
- ReAct: Synergizing Reasoning and Acting in Language Models (Yao et al.) arXiv 2210.03629
Want to learn more?
Explore more developer terms or read in-depth articles on the blog.
Browse all terms