smolagents
Read the two badges separately: the first is whether this page is backed by evidence, the second is whether the product is still maintained. An archived product can have complete evidence; complete evidence does not mean the product is active.
30-second check: should it make your shortlist?
A thin agent library from Hugging Face — it lets agents think in code. Its default…
Local / self-hosted · Framework / SDK
Open licence
Read the original licence before commercial useBlocked · Not in filing list
These four cards help you rule things out, not decide for you. The real differences are in the eight questions and sources below.
Information not confirmed
- After switching providers, the reliability alignment of tool calling / structured output (not stated officially; guided_tour and models reference pages checked)
- The default file-access scope allowed for CodeAgent (not stated officially; secure_code_execution and guided_tour pages checked)
- Deep context management spilling large tool outputs to disk (not stated officially)
- Built-in network access control mechanisms (not stated officially)
- A built-in cross-process persistence / checkpoint-resume solution (not provided officially; serialize steps yourself)
- Quotas and billing of the hosted sandboxes (Blaxel / E2B / Modal) (each decided by the provider's own pages; quotes not stored per our price-recording policy)
A thin agent library from Hugging Face — the repository description is literal: "barebones library for agents that think in code".
The core difference is code-as-action. The default CodeAgent lets the LLM write its actions as Python code and execute them, instead of emitting JSON tool calls. The official claim is that this "uses 30% fewer steps" and reaches higher scores on difficult benchmarks (README cites arXiv 2402.01030 / 2411.01747). A ToolCallingAgent that emits JSON is also provided, officially positioned for scenarios that favour reliability and structured validation — either one works.
Model-agnostic by design. Several Model classes, one per route: InferenceClientModel on the Hub's Inference Providers, plus LiteLLMModel ("100+ different models"), OpenAIModel, AzureOpenAIModel, AmazonBedrockModel, and locally TransformersModel / MLXModel / Ollama. Swapping provider means swapping a Model class.
On safety the docs are blunt. The default LocalPythonExecutor is not a security sandbox — README states it "is not a security sandbox. It applies some restrictions but can be bypassed and must not be used as a security boundary." Real isolation requires a remote sandbox: Blaxel, E2B, Modal or Docker.
When to use it, when not to
Fits: teams that buy into code-as-action (officially ~30% fewer steps than JSON tool calls) and are willing to sandbox LLM-generated code; anyone who needs model-agnostic support and local models (transformers / Ollama / mlx-lm); developers who want a thin, hackable library — Python stack; projects that want MCP / LangChain / HF Hub Space as tool sources.
Not a fit: needing a vendor-hosted always-on background or resumable runs — it is a pure library and memory is not persisted to disk; unwilling to take on arbitrary-code-execution risk but also unwilling to run a remote sandbox; wanting batteries-included filesystem / memory / sub-agent orchestration.
China availability domestic / direct access / CAC filing · snapshot 2026-10-23
- Origin
- foreign-made foreign entity (no matching filing entity in the CAC registry).
- Direct access
- direct blocked docs live on huggingface.co, which times out consistently from mainland (000 twice); pip install via PyPI measured reachable.
- CAC filing
- not in filing list:not in the CAC public registry (13 batch attachments searched 2026-10-20, https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm); the product does not serve the mainland public, so filing does not apply.
Filing status is quoted from the CAC public registry (updated batch by batch; this site copies the number and does not interpret it). "Direct access" is this site's own reachability measurement from a mainland network, not a vendor promise. GitHub-hosted sites fluctuated on the measurement day — the note says so.
8 questions, one table
8 questions, each comparable item by item with its peers.
- Model & openness
The official self-description is model-agnostic: "supports any LLM" (README, verbatim).
The implementation is several Model classes, each covering one end:
- On the HF side,
InferenceClientModelgoes through the Hub's Inference Providers. Officially named: Cerebras, Cohere, Fal, Fireworks, HF-Inference, Hyperbolic, Nebius, Novita, Replicate, SambaNova, Together
- The rest go through
LiteLLMModel(officially "100+ different models"),OpenAIModel(OpenAI and compatible endpoints, examples given for Together / OpenRouter),AzureOpenAIModel,AmazonBedrockModel
- On the local side:
TransformersModel,MLXModel,Ollama
Switching providers = swap one Model class. A
provider=parameter also works. The code structure stays the same.Unknown: after switching providers, the reliability alignment of tool calling / structured output is not stated by the official docs. (guided_tour and the models reference page checked.)
- On the HF side,
- Where it runs
A pure Python library. You run the agent loop yourself in a local process. No hosted execution service officially.
The official positioning, verbatim (README):
Official wording: "run powerful agents in a few lines of code"
Install
pip install smolagents(Python ≥3.10). It ships two CLIs:smolagent(general multi-step CodeAgent, with an interactive wizard) andwebagent(a helium-based web-browsing agent).Hierarchical multi-agent systems are expressed with
managed_agents=for delegation.The whole agent can also be shared to HF Hub as a Gradio Space via
agent.push_to_hub()(README, verbatim: "share your agent to the Hub, as a Space repository").But that is only a share / load form — not a vendor-hosted resident runtime — the process stays in your hands.
- Local files
The framework itself presets no file-system tools.
The official default toolbox (
smolagents[toolkit]) has only three items: DuckDuckGo/WebSearch, a Python code interpreter, Whisper transcription — no dedicated file read/write tool.CodeAgent reads and writes files through the Python code it generates itself (e.g.
open()) or custom tools you provide.So the file boundary comes from the execution environment, not the framework. Locally it is constrained by
LocalPythonExecutor's import allowlist. In a remote sandbox it is confined to the sandbox container. The two sandbox modes are on the secure_code_execution page.Unknown: the default file-access scope allowed for CodeAgent is not stated by the official docs. (secure_code_execution and guided_tour pages checked; no file-permission section.)
- Tasks after shutdown
Self-hosted = stop the process and it's gone; no hosted background option.
All run modes in the README are local code calls. The forms are Python API / CLI / sandbox. There is no cloud-resident or scheduled-execution form.
The only official mechanism related to "long tasks / checkpoints" is single-step execution.
agent.step(memory_step)advances one step at a time. Memory lives in-process atagent.memory. The use case on the tutorials/memory page is exactly:Official wording: "tool calls that take days"
Unknown: the official docs provide no built-in way to persist this memory and restore it in a new process (tutorials/memory and guided_tour pages checked).
So resuming after interruption means serializing steps yourself.
- Tools & extensions
The tool surface is wide, and MCP is first-class access. The README self-describes as "Tool-agnostic", with four tool sources:
- ① Custom tools — the
@tooldecorator or subclassingTool - ② MCP —
ToolCollection.from_mcp(...)reads any MCP server (installsmolagents[mcp]) - ③ LangChain tools —
Tool.from_langchain - ④ HF Hub Spaces as tools —
Tool.from_space
The default toolbox (
smolagents[toolkit]) = DuckDuckGo/WebSearch, Python code interpreter, Whisper transcription.Multi-agent systems use
managed_agents=to treat sub-agents as callable units. There are alsofinal_answer_checksfor custom termination validation.- ① Custom tools — the
- Context & memory
Context = the step history (AgentMemory); no cross-session persistence.
The official tutorials/memory page says the agent "has a memory of past steps".
Step types:
TaskStep/ActionStep/PlanningStep/FinalAnswerStep.Three official manipulation options:
agent.replay()to replay- read/write
agent.memory.stepsdirectly (the example even moves steps between two agents) step_callbacks(official example: delete old screenshots to save tokens)
There is also
planning_interval=Nto insert a planning step every N steps.The official docs position this axis as "inspect / rewrite memory", not compression.
Unknown: deep context management like spilling large tool outputs to disk is not stated by the official docs. (tutorials/memory and guided_tour pages checked.)
- Permissions & limits
The official docs are very blunt about execution safety. The default
LocalPythonExecutoris not a secure sandbox.README, verbatim:
"The built-in
LocalPythonExecutoris not a security sandbox. It applies some restrictions but can be bypassed and must not be used as a security boundary."What the local interpreter provides:
- step-by-step AST execution
- imports denied by default (open an allowlist with
additional_authorized_imports) - submodules denied by default (
numpy.*to allow all subpackages) - loop iteration caps
- undefined operations error out
For real isolation you must use a remote sandbox:
executor_type="blaxel" / "e2b" / "modal" / "docker".The official docs distinguish two modes: sandbox only the code snippets; or put the whole agent in the sandbox (the latter required for multi-agent).
There is also a Human-in-the-Loop example (examples/plan_customization), but it is not a built-in approval mechanism.
Unknown: network access control is not stated by the official docs.
- Best for
Fits these four scenarios.
- You buy into code-as-action (officially "30% fewer steps" than JSON tool calling) and are willing to sandbox LLM-generated code
- You want model-agnostic access including local models (transformers / Ollama / mlx-lm)
- You want a thin, hackable library; Python stack
- You want the MCP / LangChain / Hub Space tool ecosystem
Does not fit these three scenarios.
- You need a vendor-hosted resident background or checkpoint resume (pure library; memory is not persisted)
- You want neither arbitrary-code-execution risk nor a remote sandbox
- You want batteries-included preset file system / memory / sub-agent orchestration
Licence and terms of use
Apache-2.0
Top misconception
- Treating
LocalPythonExecutoras a security sandbox — the official docs state it is not a security boundary and can be bypassed. - Assuming it is only for writing code — the official positioning is a barebones library for *agents*;
CodeAgentjust expresses actions as code. - Assuming it ships hosted execution or resumable runs — it is a pure library: stop the process and it stops, and memory is not persisted to disk.
Evidence sources
Checked 2026-10-23,Content updated 2026-10-08。This is the date of the entry, not a claim that every field was rechecked that day.
| Type | Name | Link |
|---|---|---|
| repo | huggingface/smolagents · repository (29,996★, Apache-2.0, rolling verification 2026-10-23) | https://github.com/huggingface/smolagents |
| docs | Main README (barebones library, code-as-action, four tool kinds, sandbox options, ManagedAgent) | https://github.com/huggingface/smolagents/blob/main/README.md |
| docs | Official docs homepage (six features, CodeAgent / ToolCallingAgent positioning) | https://huggingface.co/docs/smolagents/index |
| docs | Installation options (extras list: openai/transformers/vllm/mlx-lm/litellm/bedrock/blaxel/e2b/docker/mcp etc.) | https://huggingface.co/docs/smolagents/installation |
| docs | Guided tour (the two-agent comparison, provider and local-model lists, CLI) | https://huggingface.co/docs/smolagents/guided_tour |
| docs | Secure code execution (LocalPythonExecutor not a security boundary, E2B/Modal/Blaxel/Docker, two sandbox modes) | https://huggingface.co/docs/smolagents/tutorials/secure_code_execution |
| docs | Manage your agent's memory (AgentMemory, replay, step_callbacks, single-step execution) | https://huggingface.co/docs/smolagents/tutorials/memory |
| docs | Orchestrate a multi-agent system (managed_agents delegation example) | https://huggingface.co/docs/smolagents/examples/multiagents |
| docs | What are agents? (the agency spectrum, the code-agents argument) | https://huggingface.co/docs/smolagents/conceptual_guides/intro_agents |
| changelog | Releases (latest 1.26.0 @ 2026-05-29; 1.25.0 @ 2026-05-14) | https://github.com/huggingface/smolagents/releases |
Test notes
This site has not completed measured runs. The test protocol is at protocols/framework/_protocol.md.
Suggested runs (tailored to coding-base + code-as-action dimensions):
| # | What to test | Why it is worth testing |
|---|---|---|
| 1 | How many files and lines for a minimal hello CodeAgent | tests just how thin the official "barebones / ~1000 lines" really is |
| 2 | How many classic escapes LocalPythonExecutor blocks | the official docs say it is not a security boundary — where is the real line? |
| 3 | Cost of running multi-agent with executor_type="docker" | the official docs say snippet-mode doesn't support multi-agent |
| 4 | How many lines change when switching to LiteLLM with local Ollama | verifies the real diff size of "model-agnostic" |
| 5 | Feasibility of restoring memory across processes via single-step agent.step() | no built-in persistence officially — measure the DIY checkpoint cost |
The divide with the OpenAI Agents SDK: how actions are represented
Both belong to the "primitives" tier, but the carrier of actions differs:
| Dimension | smolagents | OpenAI Agents SDK |
|---|---|---|
| Action carrier | Python code snippets (CodeAgent) or JSON (ToolCallingAgent) | function calls (function tools / handoffs) |
| Official efficiency claim | "uses 30% fewer steps" (citing arXiv 2402.01030) | no comparable quantification given |
| Execution risk | LLM code must run in a sandbox | tool calls, not arbitrary code |
| Switching providers | swap the Model class | swap the model string / adapter |
In one line: want "actions as code" and can sandbox the code → smolagents. Want tool calls + built-in guardrails/human-in-the-loop → OpenAI Agents SDK.
CodeAgent vs ToolCallingAgent (the official comparison)
The official guided_tour explains the two clearly:
| CodeAgent (default) | ToolCallingAgent | |
|---|---|---|
| Action format | Python code snippets | structured JSON |
| Strengths | high expressiveness, composable/loops/transforms, emergent reasoning | reliable, validated arguments, maps well to external APIs |
| Weaknesses | syntax/exception handling needed, needs a secure execution environment | lower expressiveness, actions must be predefined, no code synthesis |
| Fits | problem-solvers needing reasoning / chaining / dynamic composition | atomic tools, scheduler / controller style tasks |
Sandbox: the security boundary stated plainly by the official docs
The README states the default interpreter's positioning directly:
The built-in LocalPythonExecutor is not a security sandbox. It applies some restrictions but can be bypassed and must not be used as a security boundary.
What the local interpreter provides:
- step-by-step AST execution
- imports denied by default (
additional_authorized_importsallowlist) - submodules denied by default (
numpy.*to allow all subpackages) - loop iteration caps
- undefined operations error out
For real isolation the official docs give two sandbox classes:
- hosted cloud sandboxes: Blaxel, E2B, Modal (
pip install 'smolagents[blaxel|e2b|modal]') - self-hosted containers: Docker (
executor_type="docker")
Keep the two modes apart: sending only code snippets into the sandbox (simple, but unavailable for multi-agent); or moving the whole agent (model and tools included) into the sandbox (stronger isolation, but you pass credentials and set it up manually).
The relationship with HF Hub: sharing, not hosting
In the README, agents and tools are both Hub objects:
agent.push_to_hub("user/agent")publishes the agent as a Gradio Spaceagent.from_hub(...)loads community agents; same for tools
Multi-agent systems use managed_agents= (plus the official ManagedAgent wrapper class) for hierarchical delegation.
⚠ This is not "vendor-hosted execution": a Space is a share/load form; the agent loop still runs on your side, and there is no "keeps running after shutdown" semantics. Don't mistake it for a hosting service when selecting.
Verification notes
Basis for confidence: partial (2026-10-08):
All eight axes of this entry have conclusions. But items remain that the official docs genuinely don't state, recordable only as "not stated officially":
- after switching providers, the reliability alignment of tool calling / structured output
- CodeAgent's default file-access scope
- deep context management (spilling large tool outputs to disk)
- built-in network access control
These are not "couldn't find it" — the official docs themselves don't provide them, so it cannot rise to verified.
Official pages checked the 2026-10-08 check:
- README (barebones positioning, code-as-action, four tool kinds, sandbox, ManagedAgent)
- docs index
- installation (full extras list)
- guided_tour (the two-agent comparison and provider list)
- tutorials/secure_code_execution (interpreter restrictions and sandbox modes)
- tutorials/memory (AgentMemory and single-step execution)
- examples/multiagents
- conceptual_guides/intro_agents
Repo metadata verified via the GitHub API (29,996★, Apache-2.0, last push 2026-10-22, latest 1.26.0; on the 2026-10-23 rolling check 1.26.0 was still the latest release — the repo has active commits but the release cadence has slowed).
Related entries
- OpenAI Agents SDKThe pair most worth contrasting: both "primitives" tier; the divide is action representation (code-as-action vs function calls). One has built-in guardrails/HITL; the other requires you to bring your own sandbox.
- Claude Agent SDKAnother coding base from a model vendor; but that one wraps an existing CLI, while smolagents is a library where you write the loop yourself.
- CrewAIThe opposite contrast: CrewAI is an orchestration layer with the Crew/Flow dual abstraction; smolagents is thinner — just an agent library +
managed_agentsdelegation, no state-machine orchestration. - Filesystem MCP ServerOther layer · MCP tools
Same-category peers
Look at these three before reading further
Selected by overlap in jobs, not ranked. Compare where it runs, licence and status first; if one of the three fails, skip it.
| Object | Where | Licence | Evidence / status | What it is for |
|---|---|---|---|---|
| AG2 | Local / self-hosted | Open licence | 8 questions checked Active | The community continuation of AutoGen after the original repo stalled. T |
| CrewAI | Local / self-hosted | Open licence | 8 questions checked Active | "Organises multi-agent collaboration through role division and business |
| Hermes Agent | Local / self-hosted | Open licence | 8 questions checked Active | A resident personal assistant with a learning loop — put plainly: a resi |
Same vendor
More from Hugging Face
One vendor’s products are often split across categories. This list puts them together so you do not have to assemble them across five sites.
This page is generated from the ai-handbook data layer (CC BY 4.0).
For the judging criteria and method notes, see METHODOLOGY.md.