跳到主要内容Skip to main content
← Frameworks

smolagentssmolagents

Hugging Face
PythonPython 开源Open source Apache-2.0Apache-2.0 编程底座Coding framework 沙箱Sandbox MCPMCP 多AgentMulti-agent 子代理Subagents 本地模型Local models OllamaOllama partial lifecycle: active 核验Checked 2026-10-23

smolagents 是一个薄 agent 库 —— 它让 agent「用代码思考」。

官方自述是 "barebones library for agents that think in code"(仓库 description 原文)。

它最核心的设计是 code-as-action。默认的 CodeAgent 让 LLM 把动作写成 Python 代码, 并执行它。它不输出 JSON 工具调用。

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

适合:认同 code-as-action 并愿意给 LLM 生成的代码上沙箱。 要 model-agnostic 与本地模型(transformers / Ollama / mlx-lm)。 要薄、可 hack、约千行的库。 要 MCP / LangChain / Hub Space 工具生态。

不适合:需要厂商托管的常驻后台或断点续跑。它是纯库,进程关了就停、memory 不落盘。 既不愿承担任意代码执行风险又不想上远程沙箱。 想要开箱即用的文件系统 / 记忆 / 子代理编排。

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-20

出品属地Origin
国外出品foreign-made 国外主体(网信办公示名单未见对应备案主体)。foreign entity (no matching filing entity in the CAC registry).
国内使用Direct access
直连不可达direct blocked 文档站在 huggingface.co,大陆直连稳定超时(同日两次 000);pip 安装走 PyPI 实测可达。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:未见于网信办公示名单(2026-10-20 检索 13 批附件,https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm);该产品未面向大陆公众提供服务,备案不适用。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.

备案信息以网信办《生成式人工智能服务已备案信息》公示名单为准(按批次滚动更新,本站只抄编号不解读);「大陆可直连」是本站从大陆网络直连实测的结果,不是厂商承诺。GitHub 类站点当日实测有波动,口径写在依据里。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.

固定坐标系Fixed coordinate system

8 个维度dimensions, 与同分区其他对象逐项可比each comparable item by item against others in the same section.

模型与开放条件Model & openness

官方自述 model-agnostic:"supports any LLM"(README 原文)。

实现是多套 Model 类,各管一端:

  • HF 侧 InferenceClientModel 走 Hub 的 Inference Providers。官方点名这些: Cerebras、Cohere、Fal、Fireworks、HF-Inference、Hyperbolic、Nebius、 Novita、Replicate、SambaNova、Together
  • 其余走 LiteLLMModel(官方称 "100+ different models")、OpenAIModel(OpenAI 及兼容端点, 示例给 Together / OpenRouter)、AzureOpenAIModel、AmazonBedrockModel
  • 本地侧有 TransformersModel、MLXModel、Ollama

换 provider 的改动量 = 换一个 Model 类。也可加 provider= 参数。代码结构不变。

未知:换 provider 后 tool calling / 结构化输出的可靠性对齐,官方未说明。 (已查 guided_tour 与 models 参考页。)

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, InferenceClientModel goes 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.)

运行位置Where it runs

纯 Python 库。agent loop 由你自己在本地进程里跑。官方无托管执行服务。

官方定位原话(README):

官方原文:"run powerful agents in a few lines of code"

安装 pip install smolagents(Python ≥3.10)。 自带两个 CLI:smolagent(通用多步 CodeAgent,可交互式向导)与 webagent(基于 helium 的网页浏览 agent)。

分层多 agent 用 managed_agents= 表达委派。

它也可以把整包 agent 用 agent.push_to_hub() 作为 Gradio Space 分享到 HF Hub (README 原文 "share your agent to the Hub, as a Space repository")。

但那只是分享 / 加载形态,不是厂商托管的常驻运行时 —— 进程仍在你自己手里。

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) and webagent (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

框架本身不预置文件系统工具。

官方 default toolbox(smolagents[toolkit])只有三项:DuckDuckGo/WebSearch、 Python 代码解释器、Whisper 转写 —— 没有专门的文件读写工具。

CodeAgent 要读写文件。它靠的是自己生成的 Python 代码(如 open())或你提供的自定义工具。

所以文件边界由执行环境决定,框架不提供。本地跑则受 LocalPythonExecutor 的 import 白名单约束。远程沙箱跑则限在沙箱容器内。两种沙箱模式见 secure_code_execution 页。

未知:CodeAgent 默认允许的文件访问范围,官方未说明。 (已查 secure_code_execution 与 guided_tour 两页,无文件权限章节。)

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

自托管 = 进程关了就停,无托管后台选项。

README 的运行方式全是本地代码调用。形式是 Python API / CLI / 沙箱。它没有云端常驻或定时执行形态。

唯一与「长任务 / 断点」相关的官方机制是单步执行。agent.step(memory_step) 可一次只走一步。 memory 存在进程内的 agent.memory。tutorials/memory 页举的用例正是:

官方原文:"tool calls that take days"

未知:官方未提供把这些 memory 落盘并在新进程恢复的内建方案(已查 tutorials/memory 与 guided_tour 两页)。

所以断点续跑要自己序列化 steps。

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 at agent.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

工具面很宽,而且 MCP 是一等接入。 README 自述 "Tool-agnostic",工具共四个来源:

  • ① 自定义工具 —— @tool 装饰器或继承 Tool 类
  • ② MCP —— ToolCollection.from_mcp(...) 可读任意 MCP server(装 smolagents[mcp])
  • ③ LangChain 工具 —— Tool.from_langchain
  • ④ 把 HF Hub Space 当工具 —— Tool.from_space

default toolbox(smolagents[toolkit])= DuckDuckGo/WebSearch、Python 代码解释器、Whisper 转写。

多 agent 则用 managed_agents= 把子 agent 当作可调用单元。 此外有 final_answer_checks 自定义终止校验。

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 @tool decorator or subclassing Tool
  • ② MCP — ToolCollection.from_mcp(...) reads any MCP server (install smolagents[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 also final_answer_checks for custom termination validation.

上下文与记忆Context & memory

上下文 = 步历史(AgentMemory),没有跨会话持久化。

官方 tutorials/memory 页的说法是:

agent "has a memory of past steps"

步类型分 TaskStep / ActionStep / PlanningStep / FinalAnswerStep。

可操作手段官方给了三样:

  • agent.replay() 回放
  • 直接读写 agent.memory.steps(示例甚至在两个 agent 间搬 steps)
  • step_callbacks(官方示例:删掉旧截图以省 token)

另有 planning_interval=N 每 N 步插一次规划步。

官方把这一轴定位成「检查 / 改写记忆」,不是压缩。

未知:把大工具输出落盘这类深上下文管理,官方未说明。 (已查 tutorials/memory 与 guided_tour 两页。)

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.steps directly (the example even moves steps between two agents)
  • step_callbacks (official example: delete old screenshots to save tokens)

There is also planning_interval=N to 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

官方对执行安全说得非常直白。默认的 LocalPythonExecutor 不是安全沙箱。

README 原文:

"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."

本地解释器给的机制:

  • AST 逐步执行
  • import 默认禁止(用 additional_authorized_imports 开白名单)
  • 子模块默认禁止(numpy.* 才放行全部子包)
  • 循环迭代次数上限
  • 未定义操作直接报错

要真正隔离必须用远程沙箱:executor_type="blaxel" / "e2b" / "modal" / "docker"。

官方区分两种模式。一是只沙箱化代码片段。二是整包 agent 进沙箱(后者多 agent 才可用)。

官方另有 Human-in-the-Loop 示例(examples/plan_customization),但不是内建审批机制。

未知:网络访问控制,官方未说明。

The official docs are very blunt about execution safety. The default LocalPythonExecutor is not a secure sandbox.

README, verbatim:

"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 (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

适合这四类场景。

  • 认同 code-as-action(官方称比 JSON 工具调用少 30% 步数),并愿意给 LLM 生成代码上沙箱
  • 要 model-agnostic、能接本地模型(transformers / Ollama / mlx-lm)
  • 要薄而可 hack 的库;Python 栈
  • 要 MCP / LangChain / Hub Space 工具生态

不适合这三类场景。

  • 需要厂商托管的常驻后台或断点续跑(纯库,memory 不落盘)
  • 既不想承担任意代码执行风险、又不想上远程沙箱
  • 要 batteries-included 的预置文件系统 / 记忆 / 子代理编排

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

头号误解Top misconception

  • 把 LocalPythonExecutor 当安全沙箱——官方明文它 is not a security boundary,可被绕过Treating LocalPythonExecutor as a security sandbox — the official docs state it is not a security boundary and can be bypassed.
  • 以为它是「写代码专用」工具——官方定位是 barebones library for agents,CodeAgent 只是「用代码表达动作」Assuming it is only for writing code — the official positioning is a barebones library for *agents*; CodeAgent just expresses actions as code.
  • 以为接上就有托管后台或断点续跑——纯库,进程关了就停,memory 不落盘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.

未知项清单Known unknowns

  • 换 provider 后 tool calling / 结构化输出的可靠性对齐(官方未说明,已查 guided_tour 与 models 参考页)
  • CodeAgent 默认允许的文件访问范围(官方未说明,已查 secure_code_execution 与 guided_tour 两页)
  • 把大工具输出落盘的深上下文管理(官方未说明)
  • 内建网络访问控制机制(官方未说明)
  • 进程间持久化 / 断点续跑的内建方案(官方未提供,得自己序列化 steps)
  • hosted 沙箱(Blaxel / E2B / Modal)的配额与计费口径(各由服务商页决定;报价按本站的报价记录约定本站不存)
  • 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)

证据来源Evidence sources

判断可回到以下一手源复核。本站核验日Every judgement can be rechecked against the primary sources below. Verified on 2026-10-23,内容更新日content updated on 2026-10-08。

类型Type名称Name链接Link
repohuggingface/smolagents · 仓库(29,996★,Apache-2.0,滚动核验 2026-10-23)huggingface/smolagents · repository (29,996★, Apache-2.0, rolling verification 2026-10-23)https://github.com/huggingface/smolagents
docs主 README(barebones library、code-as-action、四类工具、沙箱选项、ManagedAgent)Main README (barebones library, code-as-action, four tool kinds, sandbox options, ManagedAgent)https://github.com/huggingface/smolagents/blob/main/README.md
docs官方文档首页(六大特性、CodeAgent / ToolCallingAgent 定位)Official docs homepage (six features, CodeAgent / ToolCallingAgent positioning)https://huggingface.co/docs/smolagents/index
docsInstallation options(extras 清单:openai/transformers/vllm/mlx-lm/litellm/bedrock/blaxel/e2b/docker/mcp 等)Installation options (extras list: openai/transformers/vllm/mlx-lm/litellm/bedrock/blaxel/e2b/docker/mcp etc.)https://huggingface.co/docs/smolagents/installation
docsGuided tour(两类 agent 对比、provider 与本地模型清单、CLI)Guided tour (the two-agent comparison, provider and local-model lists, CLI)https://huggingface.co/docs/smolagents/guided_tour
docsSecure code execution(LocalPythonExecutor 非安全边界、E2B/Modal/Blaxel/Docker、两种沙箱模式)Secure code execution (LocalPythonExecutor not a security boundary, E2B/Modal/Blaxel/Docker, two sandbox modes)https://huggingface.co/docs/smolagents/tutorials/secure_code_execution
docsManage your agent's memory(AgentMemory、replay、step_callbacks、单步执行)Manage your agent's memory (AgentMemory, replay, step_callbacks, single-step execution)https://huggingface.co/docs/smolagents/tutorials/memory
docsOrchestrate a multi-agent system(managed_agents 委派示例)Orchestrate a multi-agent system (managed_agents delegation example)https://huggingface.co/docs/smolagents/examples/multiagents
docsWhat are agents?(agency 谱系、code agents 论证)What are agents? (the agency spectrum, the code-agents argument)https://huggingface.co/docs/smolagents/conceptual_guides/intro_agents
changelogReleases(最新 1.26.0 @ 2026-05-29;1.25.0 @ 2026-05-14)Releases (latest 1.26.0 @ 2026-05-29; 1.25.0 @ 2026-05-14)https://github.com/huggingface/smolagents/releases

实测记录Measured runs

本档未跑集成与性能实测;结论只覆盖 API 与官方文档披露的能力面。

实测建议(按编程底座 + code-as-action 维度定制):

#测什么为什么值得测
1最小 hello CodeAgent 要几个文件、多少行验证官方「barebones / ~1000 行」的薄到什么程度
2LocalPythonExecutor 能拦住几类经典逃逸官方说它不是安全边界,实测边界在哪
3executor_type="docker" 跑通多 agent 的成本官方说明代码片段模式不支持多 agent
4换成 LiteLLM 接本地 Ollama 要改多少行验证 model-agnostic 的真实改动量
5单步 agent.step() 跨进程恢复 memory 的可行性官方无内建落盘,验证自建断点的代价

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 testWhy it is worth testing
1How many files and lines for a minimal hello CodeAgenttests just how thin the official "barebones / ~1000 lines" really is
2How many classic escapes LocalPythonExecutor blocksthe official docs say it is not a security boundary — where is the real line?
3Cost of running multi-agent with executor_type="docker"the official docs say snippet-mode doesn't support multi-agent
4How many lines change when switching to LiteLLM with local Ollamaverifies the real diff size of "model-agnostic"
5Feasibility of restoring memory across processes via single-step agent.step()no built-in persistence officially — measure the DIY checkpoint cost

与 OpenAI Agents SDK 的分野:动作怎么表示The divide with the OpenAI Agents SDK: how actions are represented

两者都属「原语型」,但表达动作的载体不同:

维度smolagentsOpenAI Agents SDK
动作载体Python 代码片段(CodeAgent)或 JSON(ToolCallingAgent)函数调用(function tools / handoffs)
官方效率说法"uses 30% fewer steps"(引 arXiv 2402.01030)未给同类量化
执行风险LLM 代码要在沙箱里跑工具调用,非任意代码
换 provider换 Model 类换 model 字符串 / 适配器

一句话:想要「动作即代码」并能给代码上沙箱,选 smolagents。想要工具调用 + 内建 guardrails/human-in-the-loop,选 OpenAI Agents SDK。

Both belong to the "primitives" tier, but the carrier of actions differs:

DimensionsmolagentsOpenAI Agents SDK
Action carrierPython 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 riskLLM code must run in a sandboxtool calls, not arbitrary code
Switching providersswap the Model classswap 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(官方对比)CodeAgent vs ToolCallingAgent (the official comparison)

官方 guided_tour 把两者讲得很清楚:

CodeAgent(默认)ToolCallingAgent
动作格式Python 代码片段结构化 JSON
强项高表达力、可组合/循环/转换、涌现推理可靠、参数经校验、与外部 API 好映射
弱项需处理语法/异常、需安全执行环境表达力低、动作必须预先定义、无代码合成
适合需要推理 / 链式 / 动态组合的问题解决者原子工具、调度器 / 控制器类任务

The official guided_tour explains the two clearly:

CodeAgent (default)ToolCallingAgent
Action formatPython code snippetsstructured JSON
Strengthshigh expressiveness, composable/loops/transforms, emergent reasoningreliable, validated arguments, maps well to external APIs
Weaknessessyntax/exception handling needed, needs a secure execution environmentlower expressiveness, actions must be predefined, no code synthesis
Fitsproblem-solvers needing reasoning / chaining / dynamic compositionatomic tools, scheduler / controller style tasks

沙箱:安全边界官方说得很清楚Sandbox: the security boundary stated plainly by the official docs

README 直接写明默认解释器的定位:

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.

本地解释器给的机制是:

  • AST 逐步执行
  • import 默认禁止(additional_authorized_imports 白名单)
  • 子模块默认禁止(numpy.* 才放行全部子包)
  • 循环迭代上限
  • 未定义操作报错

要真正隔离,官方给两类沙箱:

  • 托管云沙箱:Blaxel、E2B、Modal(pip install 'smolagents[blaxel|e2b|modal]')
  • 自托管容器:Docker(executor_type="docker")

两种模式要分清:只把代码片段送进沙箱(简单,但多 agent 不可用); 或把整个 agent(含模型、工具)搬进沙箱(隔离更强,但要传凭据、要手动搭)。

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_imports allowlist)
  • 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).

与 HF Hub 的关系:分享,不是托管The relationship with HF Hub: sharing, not hosting

README 里 agents 和 tools 都是 Hub 对象:

  • agent.push_to_hub("user/agent") 把 agent 发成 Gradio Space
  • agent.from_hub(...) 加载社区 agent;工具同理

多 agent 则用 managed_agents=(官方另有 ManagedAgent 包装类)做分层委派。

⚠ 这不是「厂商托管运行」:Space 是分享/加载形态,agent loop 仍跑在你自己那边, 也没有「关机后继续跑」的语义。选型时别把它当托管服务。

In the README, agents and tools are both Hub objects:

  • agent.push_to_hub("user/agent") publishes the agent as a Gradio Space
  • agent.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

confidence: partial 的依据(2026-10-08):

本条目八维已全部给出结论。但仍有官方确实没写、只能落「官方未说明」的项:

  • 换 provider 后 tool calling / 结构化输出的可靠性对齐
  • CodeAgent 默认的文件访问范围
  • 深上下文管理(大工具输出落盘)
  • 内建网络访问控制

这些不是「没查到」,是官方文档本身没提供,故不足以升到 verified。

已核到的官方页:

  • README(含 barebones 定位、code-as-action、四类工具、沙箱、ManagedAgent)
  • docs index
  • installation(extras 全清单)
  • guided_tour(两类 agent 对比与 provider 清单)
  • tutorials/secure_code_execution(解释器限制与沙箱模式)
  • tutorials/memory(AgentMemory 与单步执行)
  • examples/multiagents
  • conceptual_guides/intro_agents

仓库元数据经 GitHub API 核验(29,996★、Apache-2.0、最近推送 2026-10-22、最新版 1.26.0;滚动核验 2026-10-23 时 1.26.0 仍是最新 release——仓库活跃提交但发版节奏放缓)。

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 SDKOpenAI Agents SDK最该对照的一对:同为「原语型」,分野在动作表示(code-as-action vs 函数调用)。一个有内建 guardrails/HITL,一个要自己上沙箱。The 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 SDKClaude Agent SDK另一个出自模型厂商的编程底座;但那个包装既有 CLI,smolagents 是自己写 loop 的库。Another coding base from a model vendor; but that one wraps an existing CLI, while smolagents is a library where you write the loop yourself.
  • CrewAICrewAI反面对照:CrewAI 是 Crew/Flow 双抽象的编排层,smolagents 更薄,只有 agent 库 + managed_agents 委派,不做状态机编排。The opposite contrast: CrewAI is an orchestration layer with the Crew/Flow dual abstraction; smolagents is thinner — just an agent library + managed_agents delegation, no state-machine orchestration.
  • Filesystem MCP ServerFilesystem MCP Server另一层 · MCP 工具Other layer · MCP tools

本页由This page is generated from the ai-handbook 数据层生成(CC BY 4.0)。data layer (CC BY 4.0). 方法论与坐标系定义见仓库内For the methodology and coordinate definitions, see METHODOLOGY.md.