smolagents
Hugging Face's smolagents is an open source Python library for building agents that can use tools and execute tasks. CodeAgent expresses an action in Python, and ToolCallingAgent sends structured tool calls. An agent can delegate work to another agent, choose from several model providers or run with a local model. The library also provides execution controls, retained conversation steps and instrumentation for tracing a run.
Hugging Face develops smolagents as a Python library for building agents, with the core agent logic kept to about 1,000 lines of code. Its CodeAgent writes actions in Python so the model can combine tool calls, calculations, loops and conditions. ToolCallingAgent makes structured calls for applications that use that interface. The agent runs a sequence of decisions and actions until it returns a final answer or reaches a configured step limit. Application owners supply the tools and choose how the agent is invoked.
A tool can wrap a Python function with typed inputs and a description or connect to an existing MCP server. A manager agent can delegate focused work to named workers with their own tools and instructions. Agent memory retains the sequence of model and tool events, and the operator can inspect or keep those steps when continuing the same conversation. Callbacks let an application add a review after a plan, change the retained context or inspect what happened during a run, and a published example uses them to have a person approve, edit or cancel each plan. OpenTelemetry instrumentation connects model and tool events to external trace viewers such as Phoenix and Langfuse.
The library costs $0 under Apache 2.0 and installs into the user's own Python environment, and its repository has 30.3k GitHub stars. It works with any model: Hugging Face Inference Providers, OpenAI and Anthropic through LiteLLM, or a local Transformers or Ollama deployment. Model costs are billed through the service or hardware running that inference. Generated code may run in the local Python interpreter, which is not a security sandbox, or through Docker, Modal, Blaxel or E2B. The application supplies any credentials used for model inference, tool execution or external services.
One agent with search and page retrieval serves a small research application. A larger setup might give a research worker access to the web and a separate manager responsibility for deciding when the answer is complete. Tools and agents are shared to and pulled from the Hugging Face Hub, and the library includes utilities for running a basic agent from the command line. The library supplies the agent loop and tool interface, while application owners decide which services it reaches, how to store their long term data and where to run it.
Vendor details
Canonical URL
https://huggingface.co/docs/smolagents/index
Category
Agent infrastructure
Subcategory
Open source Python agent runtime
Funding status
Hugging Face product
Company status
first party product
Use cases & customers
Primary use cases
Target customers
Deployment options
Integrations
smolagents works with OpenAI, Anthropic, Hugging Face Inference Providers, Transformers and Ollama. It connects to MCP tools and can run generated code in Docker or external sandboxes.
In practice
A developer gives one worker access to approved search tools, then lets a manager ask it for evidence while combining the result with a separate computation.
An engineer runs a small agent with a local Ollama model and executes generated Python through Docker while monitoring the sequence of calls.
A build owner uses a planning callback to ask for feedback before a longer task and inspects its tool trace in a separate OpenTelemetry viewer.
Sources & related URLs
Research sources
Agentic Index coverage score
9.5 / 14 capabilities · 68%
| Integrations & Tool Calling | Full |
|---|---|
|
A tool wraps a callable in a name, description and schema that the model can use. The runtime executes that callable as part of an agent step and returns the result to the agent. It can also accept tools served over MCP or load third party tool definitions through a supported adapter. The tool owner controls credentials and what operation the callable performs. Sourcehuggingface.co/docs/smolagents/tutorials/toolsread 2026-11-21 |
|
| Workflow Orchestration | Full |
|
A manager can delegate part of a request to an agent registered as a managed worker. That worker has a name, a description and its own tool set, and it returns the result to the caller. The manager combines the output with other steps in its run. Each agent tracks its own steps, and a CodeAgent can compose calls with loops, conditions and intermediate results. Sourcehuggingface.co/docs/smolagents/examples/multiagentsread 2026-11-21 |
|
| Knowledge Grounding & RAG | Partial |
|
A retrieval tool can take a query from the agent, fetch passages from a source and return them as context for the next decision. The agent may rewrite a query or make several lookups during one run. The retrieval example uses a separate document retrieval component. The agent runtime consumes the results while index creation and refresh belong to the connected store. Sourcehuggingface.co/docs/smolagents/examples/ragread 2026-11-21 |
|
| Human Oversight & Guardrails | Partial |
|
A planning callback can interrupt the agent after it creates a plan, present it to a person and use feedback to change the next steps. The application owns that interactive approval logic and resumes the run with its existing state. The Python interface supports the pause and continuation. A specific tool action runs under permissions and approval logic supplied by the tool owner. Sourcehuggingface.co/docs/smolagents/examples/plan_customizationread 2026-11-21 |
|
| Security, Identity & Governance | Not documented |
|
CodeAgent restricts imports in its local interpreter and can place generated code in a separate execution sandbox. Docker and external runtimes offer different isolation paths for the executable snippets. The operator manages authentication and access to the surrounding app and tools. Hugging Face Hub account controls and assurance apply to its hosted offering, outside the installable runtime. Sourcehuggingface.co/docs/smolagents/tutorials/secure_code_executionread 2026-11-21 |
|
| Observability & Auditability | Full |
|
Instrumentation emits traces when a smolagents run executes. Nested steps associate a manager with its workers, model calls and tool results. OpenTelemetry carries the execution record to configurable external viewers such as Phoenix or Langfuse. The agent's own step memory also supports replay so the sequence of actions and observations remains inspectable after a run. Sourcehuggingface.co/docs/smolagents/tutorials/inspect_runsread 2026-11-21 |
|
| Memory & State Persistence | Partial |
|
Agent memory retains the task, plans, tool calls and observations for a sequence of steps. The caller can preserve that state when it resumes an interrupted run or asks a follow up question. A callback can remove selected content such as older screenshots from the context. Retained steps are attached to the current agent instance, with persistence across independent sessions left to the application. Sourcehuggingface.co/docs/smolagents/tutorials/memoryread 2026-11-21 |
|
| Deployment & Data Residency | Full |
|
The Python distribution installs in a customer controlled environment and runs the agent loop there. The operator can keep execution local, connect a Docker environment or route generated code to a chosen sandbox service. Local models and external inference are also configured separately. The operator chooses where generated code, stored inputs and agent execution live. Sourcepypi.org/project/smolagentsread 2026-11-21 |
|
| Prebuilt Agents / Templates / Packs | Partial |
|
CodeAgent and ToolCallingAgent provide reusable execution styles, and the installable package includes tools for tasks such as web search and page retrieval. Runnable examples show how to assemble tools and agents for a problem. Agent configurations can also be shared through Hugging Face Hub, with the sources, credentials and workflow still supplied by the application owner. Sourcehuggingface.co/docs/smolagents/indexread 2026-11-21 |
|
| Triggers & Channel Coverage | Partial |
|
The Python interface runs an agent when the application passes it a task, and the command line utility provides an interactive way to start a request. An application can stream the resulting steps into its own interface. The agent loop starts from that invocation, with recurring jobs or inbound event subscriptions supplied by the application that calls the library. Sourcehuggingface.co/docs/smolagents/en/reference/agentsread 2026-11-21 |
|
| Model Flexibility & Routing | Full |
|
Model adapters let the application owner choose the provider and model behind an agent. Options include Hugging Face Inference Providers, OpenAI or Anthropic through compatible interfaces, and local models served through Transformers or Ollama. The same project may use different configurations for separate agents. Credentials and local inference settings stay with the chosen adapter. Sourcehuggingface.co/docs/smolagents/examples/using_different_modelsread 2026-11-21 |
|
| APIs / SDKs / MCP Extensibility | Full |
|
An outside program creates the library's own agent objects and calls the run methods through Python. The interface configures tools, models, managed workers and callbacks and can return streamed steps to the caller. Agent objects can also be saved and loaded through the supported configuration methods. The command line tools expose common agent invocations to scripts and interactive use. Sourcehuggingface.co/docs/smolagents/en/reference/agentsread 2026-11-21 |
|
| Testing, Debugging & Optimization | Partial |
|
A run keeps its recorded actions and observations available for replay, including a more detailed view of step memory. A caller can examine what the agent generated and what each tool returned, and telemetry can export the same sequence for debugging. Benchmark examples supply their own tasks and scoring around the library. The runtime itself supplies inspection without a reusable scoring suite. Sourcehuggingface.co/docs/smolagents/tutorials/memoryread 2026-11-21 |
|
| Browser / Computer-use | Partial |
|
The default page retrieval tool fetches a URL during the agent run and returns its text for subsequent reasoning. Search is available through a separate tool. A browser example adds visual operations using a browser and tools wired in by the application owner. The library itself carries the page retrieval surface without operating a rendered desktop or browser of its own. Sourcehuggingface.co/docs/smolagents/reference/default_toolsread 2026-11-21 |
|
The Agentic Index coverage score grades every vendor Full, Partial or Not documented against the same 14 buyer facing capabilities, from public evidence only. Each capability links to how all vendors in the index score on it. How this evidence is graded
Pricing
$0 for the Apache 2.0 Python library
No library fee, with separate inference and infrastructure costs
What is public
Hugging Face's smolagents library costs $0 under Apache 2.0.
Billing mechanics
Inference and sandbox usage follow the connected providers' terms. Local execution runs on infrastructure supplied by the operator.
Additional watchouts
External model, sandbox and tool accounts are separate from the library license.
Sales call required
No, self serve available
Free / trial
$0 open source install
Commercial notes
The same package contains CodeAgent, ToolCallingAgent and the interfaces for tools and model configuration.
Related vendors
- AgentOps — Agent observability and debugging platform: open source SDKs trace…
- AgentPhone — AgentPhone gives the AI agents a team builds their own US or…
- Agno — Python agent framework and AgentOS runtime (formerly Phidata) for…
- Airbyte — Airbyte moves data from operational systems into warehouses and…
- AIsa — Resource and payment gateway for AI agents, with one key to 110+…
- Albato — Albato is a no code integration platform that sells an embedded,…
Alternatives to smolagents
Other products that do the work smolagents does, and what each one is.
- PipecatOpen-source framework for building real-time voice and multimodal AI agents
- SmythOSOpen source runtime and TypeScript SDK for building and running AI agents in production
- AlbatoNo code integration platform
- Alteryx
- DigitalOceanDeveloper cloud
- GPT ResearcherOpen-source autonomous research agent