An AI agent is a software system that autonomously performs tasks and makes decisions on a user’s behalf. A language model can help it interpret a request and choose what to do next, while tools let it act outside the model. A prompt sent to a model followed by a fixed automation sequence is not, by itself, the same thing as an agent. section 13.4
The reason to use an agent is operational: a single model response may not be enough. Context windows can lose earlier conversation, models can struggle with calculation or logic, and supplied context can be outdated or wrong. An agent can break a task into steps, call tools for information or action, and use the results to decide what to do next. Memory management and access to current information are related needs, not automatic properties of every agent. section 13.4 section 13.5
The core capabilities are:
- Reason: analyze the request and available context, then determine the next step. section 13.4
- Act: execute a step through an external tool or API, rather than only describing an action. section 13.4
- Interact: communicate with users or other agents when collaboration is needed. section 13.4
A local implementation can pair a small language model with smolagents’ CodeAgent and Python tools. CodeAgent writes and runs Python snippets for its steps instead of producing JSON action instructions. Custom tool functions need type hints and docstrings so their capabilities are available to the agent. The configured tool set and step limit define what a particular run can attempt; adding a domain-specific tool expands the actions available. section 13.4 section 13.5
from smolagents import CodeAgent
custom_tools = [search_for_flights, find_seat]
agent = CodeAgent(tools=custom_tools, model=model,
verbosity_level=2, max_steps=2)
This configuration gives CodeAgent flight-search and seat-selection tools and limits the run to two steps. section 13.4
Chaining actions
For a flight request, an agent can search for flights, pass a returned flight code to a seat-selection tool, and, when a booking tool is added, pass the flight and seat to that tool. The example booking function is a mock; its ticket number demonstrates the workflow rather than a real purchase. section 13.4
In agentic retrieval-augmented generation, the agent chooses how to gather context before answering. It might search local documents, revise a query when results are unhelpful, or use web search. One implementation equips CodeAgent with BM25, semantic, hybrid, and web-search options. Tool choice becomes part of the workflow rather than a fixed retrieval step. section 14.2
































