
smolagents
Open-source Python library for building agents that act by writing code
smolagents is an open-source agent framework for multi-agent frameworks. It is available on API, CLI, Self-hosted, Linux, macOS and Windows.
- Pricing
- Open source
- Platforms
- API, CLI, Self-hosted
- GitHub stars
- 30.6K
- Last commit
- Language
- Python
- License
- Apache-2.0
Similar agents
About smolagents
Rather than asking a model to emit JSON tool calls, smolagents lets the model write short Python snippets that call tools as ordinary functions, so loops, conditionals and nested calls come for free. The core agent logic is kept deliberately small, which makes it practical to read the source and keep only the pieces you need.
The library works with many model backends: Hugging Face inference providers, OpenAI-compatible endpoints, Anthropic and others through LiteLLM, and local models run with Transformers, Ollama or llama.cpp. Tools can come from MCP servers, LangChain, or a Hugging Face Space. Agents and tools can be pushed to and pulled from the Hub.
Generated code can be run in sandboxes provided by E2B, Blaxel, Modal or Docker. The bundled local executor is explicitly not a security boundary, so untrusted code should always go through one of those isolated options. Developers who want to build custom multi-step agents in Python are the main audience, with a companion CLI for running agents without writing boilerplate.
What it does
- Code-writing agents
- The CodeAgent expresses each action as Python code, letting tool calls be composed with loops and conditionals.
- JSON tool-calling mode
- ToolCallingAgent offers the conventional JSON or text tool-call style for cases where it is preferred.
- Model-agnostic backends
- Works with Hub-hosted models, OpenAI-compatible APIs, LiteLLM providers and local Transformers, Ollama or llama.cpp models.
- Sandboxed execution
- Generated code can run in E2B, Blaxel, Modal or Docker sandboxes instead of the host machine.
- MCP and LangChain tools
- Agents can use tools exposed by any MCP server or imported from LangChain, and Hub Spaces as tools.
- Command-line runner
- The smolagent and webagent commands run agents directly from the terminal, with an interactive setup mode.
Good for
- Prototype a small research agent that searches the web and runs calculations in one script
- Run a local open-weight model as the reasoning engine for a private automation task
- Chain multiple tools from an MCP server into a single agent workflow
- Automate browser-based tasks such as gathering product details with the webagent command
Pricing
Open source
Free open-source library under Apache-2.0; sandbox and hosting costs depend on the provider used.
Prices change. Check huggingface.co before you buy.
smolagents FAQ
Is smolagents free to use?
It is an open-source Python library released under the Apache-2.0 license, so the library itself costs nothing to install and use.
Is the local code executor safe for untrusted code?
No. The built-in LocalPythonExecutor applies some restrictions but is not a security sandbox, so untrusted code should run in E2B, Blaxel, Modal or Docker.
Which language models can smolagents use?
Any model reachable through Hugging Face inference providers, OpenAI-compatible servers, LiteLLM (including OpenAI and Anthropic), Azure, Amazon Bedrock, or local Transformers, Ollama and llama.cpp models.
What are the best alternatives to smolagents?
The closest alternatives to smolagents are llm_agents, OpenProgram, lagent, atomic-agents and llama-cpp-agent.
Where this comes from
- Description: written from the project's README and the project's website.



