smolagents
Select smolagents when code actions make a tool workflow easier to express, and isolate execution independently.
- Starting price
- Apache-2.0 library; runtime charges separate
- Free access
- No library licence fee; inference not included
- Billing unit
- Software licence plus model, tool and sandbox usage
- Platform
- Python; local or hosted models. Icon shows the Hugging Face maintainer mark.
- Verified
- 31 Oct 2026
Overview
What you provide
- Provide a bounded task, a configured model and explicitly permitted tools or data sources.
What you get
- The agent produces an answer and an inspectable sequence of code actions or tool calls.
Choosing this tool
smolagents lets CodeAgent produce Python actions rather than only JSON tool calls, while ToolCallingAgent supports a conventional tool-calling loop. This can help with composable computations, but generated code introduces a distinct execution boundary. Compare PydanticAI for a typed Python agent interface or LangGraph for explicit stateful graph orchestration. The documented LocalPythonExecutor offers best-effort restrictions and is explicitly not a security sandbox.
A decision worked through
The licence component is USD 0, but a hosted run still adds inference, tool and sandbox charges. Without a chosen model, token volume and sandbox tariff, a total per-run estimate cannot be calculated from the library licence.
smolagents alternatives for python agents that execute code and call tools
Compare smolagents with PydanticAI, LangGraph for this workflow, including the billing unit and the work left to your team.
| Product | Price / unit | Free allowance | Input → output | Key limit |
|---|---|---|---|---|
| smolagentsRead profileOfficial source ↗ | Apache-2.0 library; runtime charges separate | No bundled inference allowance | A task drives code actions or tool calls. | LocalPythonExecutor is not a sandbox. |
| PydanticAIRead profileOfficial source ↗ | MIT software; infrastructure separate | No self-hosted software licence fee | Typed tasks become Python-agent results. | Model services and observability are separate choices. |
| LangGraphOfficial source ↗ | MIT software; infrastructure separate | No self-hosted software licence fee | State and nodes form a controllable agent graph. | You design state, persistence and execution policy. |
Setup & workflow
- Install the documented toolkit package and run a bounded computation example.
- Choose code actions or conventional tool calls for the actual workflow.
- Inspect traces and isolate any execution before connecting sensitive systems.
Requirements & installation
- Use a compatible Python environment, install the toolkit extra and configure model access before adding tools.
pip install "smolagents[toolkit]"Limits & review
- The built-in local executor is not a security boundary. No universal model-memory requirement is stated; local hardware needs depend on the selected model and context.
Your part
- Review tool authority and generated code, and choose an isolated executor appropriate for the data and commands.
Sources & verification6
This profile is based on official sources, not a hands-on product test.
Vendor descriptions and demos document advertised features. Editorial guidance is based on these sources.
- Official smolagents pricinghuggingface.co
- Official smolagents producthuggingface.co
- Official smolagents code and execution boundarygithub.com
- smolagents official referencehuggingface.co
- PydanticAI official referencegithub.com
- LangGraph official referencegithub.com