smolagents: Hugging Face's minimalist agent library
smolagents is a small open source Python library (Apache 2.0) from Hugging Face for building an AI agent in just a few lines. Its signature move: the agent acts by writing and running Python code instead of filling in JSON tool calls.
Data as of October 22, 2026
Key figures
| Developer | Hugging Face |
|---|---|
| Type | Code |
| Languages | Python |
| Open source | Yes |
| License | Apache-2.0 |
| First release | December 2024 |
| Suggested level | Beginner |
| Use cases | automation, data, multi-agent |
| Self-hostable | Yes |
| Business model | Free |
| Cloud offering | No |
| Multi-agent | Yes |
| MCP support | Yes |
| Bring your own model | Yes |
| Official site | Official site · Documentation · Repository |
GitHub
| Repository | huggingface/smolagents |
|---|---|
| GitHub stars | 29,984 |
| Forks | 3,128 |
| Latest code activity | October 22, 2026 |
| Latest release | v1.26.0 (May 29, 2026) |
GitHub activity checked on October 22, 2026.
The idea: less abstraction, more code
Hugging Face released smolagents in late 2024 with a simple promise: an agent’s whole logic should fit in a small, readable codebase. Where many frameworks stack layer upon layer, smolagents stays close to how an AI agent actually works: the model reasons, picks an action, observes the result and repeats, following the ReAct pattern.
You get two kinds of agents:
- CodeAgent, the house specialty: at each step the model writes a short Python snippet that calls tools, does math or combines results;
- ToolCallingAgent, for classic JSON-based tool calling when that style fits better.
Tools can come from an MCP server, from LangChain, or even from an app published on the Hugging Face Hub. Several agents can also work together, with one managing the others.
Who it’s for, and what for
smolagents is a good way to learn what an agent really is, prototype quickly, or build agents for web research, data analysis and file processing. It’s a natural fit for open-weight models, since it works just as well with a local model as with a commercial API. Agents can also take image, video or audio inputs.
Up and running in minutes
After a pip install of the smolagents package (with the “toolkit” extra for default tools such as web search), you pick a model, create a CodeAgent with a list of tools and hand it a task. Ready-made commands, smolagent and webagent, even let you try it without writing a script.
Strengths and limits
Strengths: simplicity, transparency (you can read the code the agent writes), model independence and Hub integration.
Limits: running generated code calls for serious sandboxing in production; quality depends heavily on the model, since smaller models write less reliable code; and there’s no visual interface or advanced state management and resumption like heavier frameworks offer.
Alternatives
For production work with fine-grained control, look at LangGraph or Pydantic AI. For an official vendor SDK, consider the OpenAI Agents SDK or Google ADK.
Frameworks of the same type
Frequently asked questions
Why would an agent write code?
An agent that thinks in Python can chain several tools, loop or calculate in a single step, whereas JSON tool calling handles one call at a time. The trade-off is that this code has to run in a controlled environment.
Is it risky to run code the agent writes?
It can be if the code runs directly on your machine. That's why smolagents supports sandboxed execution through Docker or services such as E2B, Modal or Blaxel. While experimenting, don't give the agent access to sensitive files or accounts.
Do I have to use Hugging Face models?
No. smolagents works with models hosted on the Hub, with OpenAI, Anthropic and many other providers through LiteLLM, or with local models via Transformers or Ollama.
Does smolagents cost anything?
No, the library is free. You only pay for the model you use (API or inference provider) and, if you pick one, the sandbox service.
Data sources
- github.com
- huggingface.co
- pypi.org
- GitHub — Repository metadata: GitHub
Data as of October 22, 2026
Report an error
Does a figure, a date or a fact look wrong? Tell us: every report is checked.