---
title: "smolagents：功能、版本和快速入门 · DotsAgent"
description: "Hugging Face 维护的 smolagents：许可证、最新版本、MCP 支持、持久化运行、人工审批、追踪和评测，并附有可复制的快速入门。"
url: https://dotsagent.io/zh/frameworks/smolagents
---

框架 · Hugging Face

# 快速了解 smolagents

Hugging Face 的轻量级 Python 库，代码量约千行；它的 CodeAgent 会用 Python 代码编写操作，并在 Modal、E2B 或 Docker 等沙箱中运行。代理和工具也可以分享到 Hub。

**适用于：**  学习和研究，尤其适用于通过编写代码来执行操作的代理。

## 关键信息

- **维护者**: Hugging Face
- **语言**: Python
- **许可证**: Apache-2.0
- **最新版本**: `1.26.0` · 2026年5月29日
- **代码仓库**: [huggingface/smolagents](https://github.com/huggingface/smolagents) · 29,617 个 stars
- **托管选项**: 无

## 快速入门

安装软件包、设置凭据，然后运行官方文档中的最简 agent。这里使用的模型 ID 与文档一致，但你的账户可能尚未启用这些模型。

`安装`

```
pip install 'smolagents[toolkit]'
```

需要 HF token for Inference API

`Python`

```
from smolagents import CodeAgent, InferenceClientModel

# Initialize a model (using Hugging Face Inference API)
model = InferenceClientModel()  # Uses a default model

# Create an agent with no tools
agent = CodeAgent(tools=[], model=model)

# Run the agent with a task
result = agent.run("Calculate the sum of numbers from 1 to 10")
print(result)
```

[快速入门来源](https://huggingface.co/docs/smolagents/index)

## 功能

| 支持任意模型 | — | HF Inference Providers、LiteLLM、本地 Transformers 和 Ollama |
| --- | --- | --- |
| MCP 客户端 | — | 来自任意 MCP server、LangChain 或 Hub Spaces 的工具 |
| MCP 服务器 | — | — |
| 多 agent | — | 代理可以协调其他代理 |
| 持久化运行 | — | — |
| 人工审批 | — | — |
| 追踪 | — | — |
| 评测 | — | — |

## 近期更新

- 自 2026 年 5 月 29 日发布 1.26.0 后，PyPI 上没有新版本；不过该仓库在 2026 年 9 月下旬仍有提交。

## 同一语言的替代方案

- [OpenAI Agents SDK](https://dotsagent.io/zh/frameworks/openai-agents-python)

- [Claude Agent SDK](https://dotsagent.io/zh/frameworks/claude-agent-sdk)

- [Google ADK](https://dotsagent.io/zh/frameworks/google-adk)

- [Microsoft Agent Framework](https://dotsagent.io/zh/frameworks/microsoft-agent-framework)

- [LangGraph](https://dotsagent.io/zh/frameworks/langgraph)

- [CrewAI](https://dotsagent.io/zh/frameworks/crewai)

## 来源

1. [huggingface.co](https://huggingface.co/docs/smolagents/index)/docs/smolagents/index
2. [pypi.org](https://pypi.org/pypi/smolagents/json)/pypi/smolagents/json
3. [api.github.com](https://api.github.com/repos/huggingface/smolagents)/repos/huggingface/smolagents

为 AI agent 开发者提供的独立参考资料。与此处提及的任何厂商均无关联。

© 2026 DotsAgent · 事实核查日期：2026年10月1日
