In this module, we will explore the pros and cons of using smolagents, helping you make an informed decision about whether it’s the right framework for your needs.
An agentic framework is not always needed when building an application around LLMs. They provide flexibility in the workflow to efficiently solve a specific task, but they’re not always necessary. Sometimes, predefined workflows are sufficient to fulfill user requests, and there is no real need for an agentic framework. Even if the agentic approach is low-level, like chains or routers, using plain code may be enough since the developer will have full control and understanding of the system.
However, when the workflow becomes more complex, such as letting an LLM call functions (tool calling) or execute multiple steps (multi-step agent), these abstractions start to become necessary.
Considering these ideas, we can already identify the need for some features:
smolagents is a simple yet powerful framework for building AI agents. It provides LLMs with the agency to interact with the real world, such as calling search or image generation tools. AI agents are programs where LLM outputs control the workflow.
Unlike other frameworks where agents write actions in JSON that require parsing, smolagents focuses on direct tool calls in code, simplifying the execution process. The following diagram illustrates this difference:

Agents in smolagents inherit from MultiStepAgent, enabling them to operate in multiple steps, where each step consists of:
There are two types of agents available:
We will explore each agent type in more detail in the following units.
Note: In smolagents, tools are defined using
@toolor theToolclass. They are distinct fromToolCallingAgent. BothCodeAgentsandToolCallingAgentutilize tools. Keep this distinction in mind throughout the rest of the unit to avoid confusion!
smolagents supports flexible LLM integration, allowing you to use any callable model as long as it meets certain criteria. To simplify connections with various model types, the framework provides predefined classes:
transformers pipeline for seamless integration.This flexibility ensures that developers can choose the most suitable model integration for their specific use cases.
All the previously mentioned functionality is available in smolagents. So the question becomes: when should we use smolagents instead of other possible frameworks?
You may choose smolagents if:
Join us as we dive deep into smolagents in the upcoming sections!