
Smolagents is an open-source Python library from Hugging Face designed to make building and running AI agents as straightforward as possible. The library was built around a philosophy of radical minimalism — the entire core logic fits in roughly a thousand lines of code, keeping abstractions close to raw code and avoiding the bloat that characterizes heavier frameworks.
At the heart of smolagents is the CodeAgent, which takes an unconventional approach to tool use: instead of generating JSON blobs to call tools, it writes actual Python code to accomplish tasks. This means agents can naturally compose operations using function nesting, loops, and conditionals — patterns that feel native to developers and allow for more expressive, flexible behavior than traditional JSON-based tool calling. For teams that prefer the conventional approach, ToolCallingAgent supports standard JSON/text-based tool-calling as well.
Smolagents is model-agnostic by design. It connects to models hosted on the Hugging Face Hub via Inference Providers, OpenAI, Anthropic, and virtually any other provider through LiteLLM integration, or locally via Transformers and Ollama. This flexibility means teams are not locked into any particular model vendor and can swap models as capabilities or costs change.
The library is also tool-agnostic, supporting tools from MCP servers, LangChain, and even Hugging Face Spaces — a unique integration that lets developers expose any Gradio Space as a callable tool. Sharing and loading agents and tools through the Hugging Face Hub is natively supported, reducing friction for teams that already operate within that ecosystem.
Beyond text, smolagents handles vision, video, and audio inputs, making it applicable to multimodal workflows. Secure code execution is supported through sandboxed environments via Modal, Blaxel, E2B, or Docker — a critical consideration when running agent-generated code in production.
Compared to alternatives like LangChain or LlamaIndex, smolagents occupies a different position: it prioritizes simplicity and a small footprint over comprehensive abstractions and pre-built integrations. CrewAI and AutoGen offer richer multi-agent orchestration out of the box, but smolagents provides explicit multi-agent examples and keeps the orchestration logic transparent and hackable. For developers who want full visibility into what the framework is doing and prefer to build up complexity themselves rather than inherit it from a large framework, smolagents is a natural fit.
CLI utilities (smolagent, webagent) are included for running agents without writing boilerplate, and the library ships with built-in tools like DuckDuckGo web search. The documentation includes tutorials covering memory management, telemetry for inspecting agent runs, agentic RAG, text-to-SQL, and human-in-the-loop workflows.
Smolagents is fully open-source and free to use under its open-source license. Costs, if any, come from the underlying model providers (such as Hugging Face Inference Providers, OpenAI, or Anthropic) and any sandboxed execution infrastructure chosen by the developer.
Smolagents is best suited for Python developers and ML engineers who want a transparent, minimal foundation for building AI agents without the overhead of a large framework. It is particularly well-matched for teams already embedded in the Hugging Face ecosystem, and for use cases that benefit from code-executing agents — such as data analysis, automated workflows, and agentic RAG pipelines where flexible, composable logic is more important than pre-built scaffolding.