What it is
smolagents is a small agent library from Hugging Face. Its main class, CodeAgent, writes each action as a short Python snippet that calls tools, loops or computes values, instead of emitting one JSON tool call at a time. A ToolCallingAgent is available for the classic JSON style.
Because the agent runs code it wrote itself, the README says to use a sandbox: E2B, Blaxel, Modal or Docker. The built-in LocalPythonExecutor is, in the README's words, not a security boundary.
It works with local transformers or Ollama models, Hugging Face inference providers, and commercial APIs through LiteLLM, and can load tools from MCP servers, LangChain and Hub Spaces. The last release, v1.26.0, was on 29 May 2026; commits since August have been CI and security housekeeping.
Our review
smolagents is better as a lesson than as a dependency. Its last release, v1.26.0, came on 29 May 2026 after roughly two a month through early 2026. Commits continued, but those since August pin GitHub Actions, scope tokens and bump the docs builder; none adds features. Against about 30,000 stars sit 405 open issues and 590 open pull requests.
The idea remains sound and well argued. Writing an action as code lets an agent chain several tool calls, loops and conditionals in one step; the README cites research showing 30% fewer steps, and so fewer model calls, than JSON tool calling. The core agent logic is under 1,000 lines, short enough to read in an afternoon.
The security model is the catch. Running model-written Python safely needs a real sandbox, and the local executor has already been broken: CVE-2025-5120 and CVE-2025-9959 were sandbox escapes in LocalPythonExecutor, and the README now says plainly it is not a security boundary. E2B, Blaxel, Modal or Docker add a second service to run and pay for.
For durable production agents, Pydantic AI and LangGraph offer typed outputs, persistence and tracing that smolagents leaves to you, with steadier release trains. The Hugging Face Hub integration, including pushing a whole agent to a Space, remains something neither rival matches.
Where it earns its place
An ML researcher comparing open models on agent tasks
Benchmark how well a Hub model plans and calls tools
Swap models through the Hub or Ollama with the same CodeAgent and the repo's benchmark script; the library is free and the cost is inference.
An engineering lead teaching a team how agents work
Show the agent loop end to end without framework abstractions
The under-1,000-line agents.py is readable in a session; pair it with a Docker sandbox so exercises never run generated code on laptops.
A CTO weighing an agent framework for a two-year product
Decide whether to standardise on smolagents
Five months without a release and 590 open pull requests are a maintenance risk; budgeting to fork or migrate later, or choosing a framework with steadier releases, is the cautious option.
Before you commit
- Setup
- pip install "smolagents[toolkit]" on Python 3.10 or newer; a first CodeAgent with a Hub or API model runs in a few lines. Add an E2B, Modal, Blaxel or Docker sandbox before running untrusted input.
- Integrations
- Models via transformers, Ollama, Hugging Face inference providers and LiteLLM; tools from MCP servers, LangChain and Hub Spaces; agents can be pushed to and pulled from the Hub.
- Data and privacy
- Apache 2.0. Nothing is sent anywhere beyond the model and sandbox providers you configure. CVE-2025-5120 and CVE-2025-9959 were sandbox escapes in LocalPythonExecutor, which the README says must not be used as a security boundary.
- Cost at scale
- The library is free; the bill is model tokens plus sandbox time on E2B, Modal or Blaxel, or your own Docker hosts.
- Limits
- 405 open issues and 590 open pull requests; no release since 29 May 2026. No built-in persistence or durable execution.
What's good
- Code-as-action design cuts model calls
- Core logic under 1,000 lines
- Any model via transformers, Ollama, Hub providers or LiteLLM
- Tools from MCP, LangChain and Hub Spaces
What's not
- No release since May 2026; recent commits are housekeeping
- Local executor has had sandbox-escape CVEs
- Few production features: persistence, typed outputs, tracing
- 590 open pull requests
Best for
Researchers and learners exploring code-writing agents, especially with open models.
Alternatives
smolagents: common questions
- Is smolagents worth it?
- A clear demonstration that agents can act in code, now drifting into maintenance mode with 590 pull requests waiting. We rate it 3.5 out of 5.
- How much does smolagents cost?
- Free and open source under the Apache 2.0 license.
- What are the downsides of smolagents?
- No release since May 2026; recent commits are housekeeping; local executor has had sandbox-escape CVEs; few production features: persistence, typed outputs, tracing; 590 open pull requests.
- Who is smolagents best for?
- Researchers and learners exploring code-writing agents, especially with open models.
- How much does smolagents cost for a team or in production?
- The library is free; the bill is model tokens plus sandbox time on E2B, Modal or Blaxel, or your own Docker hosts.
- Is smolagents safe for company data?
- Apache 2.0. Nothing is sent anywhere beyond the model and sandbox providers you configure. CVE-2025-5120 and CVE-2025-9959 were sandbox escapes in LocalPythonExecutor, which the README says must not be used as a security boundary.
- What are the best smolagents alternatives?
- The closest alternatives we have reviewed are Pydantic AI, OpenAI Agents SDK and LangGraph.
Answers checked Oct 23, 2026.