SmolAgents

让开发者仅用几行代码即可构建和运行强大的AI智能体

In-depth Report

  • SmolAgents is an open source lightweight AI Agent framework developed by Hugging Face, designed to allow developers to build and run powerful agents with only a few lines of code. The framework adopts the "small but refined" design philosophy. The core code is only about 1,000 lines, but it implements powerful intelligent agent functions. The core innovation of SmolAgents is its "Code Agents" approach - agents write and execute Python code to complete tasks, rather than generating traditional JSON or text-formatted actions. This design significantly improves execution efficiency and can reduce execution steps and the number of LLM calls by approximately 30% compared to standard tool calling methods. In the 2025 benchmark test, the open source model agent built based on SmolAgents successfully topped the GAIA evaluation, indicating that the open source model is now comparable to commercial closed source models in terms of complex task processing capabilities. SmolAgents supports more than 40 large language models, including models on Hugging Face Hub, third-party models such as OpenAI, Anthropic, and locally deployed Transformers and Ollama models. Currently, the framework has received more than 27,000 stars on GitHub, showing high recognition by the developer community.

  • SmolAgents was officially released by the Hugging Face team in January 2025. It is an important product of the company in the field of large language model applications. As a leader in the open source machine learning community, Hugging Face has been committed to lowering the threshold for using AI technology. The birth of SmolAgents stems from the team's reflection on the over complexity of the existing Agent framework - traditional frameworks often require a large amount of code and complex configuration to achieve basic functions, which is contrary to the concept of democratization of AI technology. The design concept of this framework emphasizes "minimalism" and compresses the core logic of the Agent to about 1,000 lines of code. This design makes the framework easy to understand and modify, and developers can have a deep understanding of the working principle of the Agent instead of being troubled by complex abstraction layers. In September 2025, SmolAgents added visual support, further expanding its application scope. SmolAgents was developed by Hugging Face’s core team members, including Aymeric Roucher, Albert Villanova del Moral, Thomas Wolf, Leandro von Werra and Erik Kaunismäki. These developers are active contributors to the open source community and have extensive experience in the fields of large language models and Agent technology. As a leader in the field of open source machine learning, Hugging Face has strong technical accumulation and community resources, providing a solid technical foundation and ecological support for the development of SmolAgents.

  • SmolAgents provides a number of core features that make it stand out among many Agent frameworks. The first is the CodeAgent function, which is a first-level support feature of the framework that allows agents to write operations in Python code instead of generating actions in JSON or text format. This method is more natural and flexible, and the expressive power of the code far exceeds the structured JSON format. The framework supports multiple model access methods. InferenceClientModel supports models on Hugging Face Hub, LiteLLMModel supports more than 100 LLMs (including OpenAI, Anthropic, etc.), OpenAIModel supports any OpenAI compatible API, TransformersModel supports local model reasoning, and AzureOpenAIModel and AmazonBedrockModel support enterprise-level cloud services. This model-agnostic design allows developers to make flexible choices based on their needs. SmolAgents also supports deep integration with Hugging Face Hub, so developers can easily share and pull tools or agents on the Hub. In addition, the framework supports multiple input modalities, including text, visual, video, and audio. In terms of tool integration, the framework supports MCP server tools, LangChain tools, and Hub Space as tools. The framework also provides command line tools (CLI), including smolagent and webagent commands, to facilitate rapid development and testing. The technical architecture of SmolAgents is very simple. The core of the framework is the Agent loop. After the agent receives the user's task, it generates code or tool calls through the large language model, then runs the code or calls tools in the execution environment, and finally returns the results to the user. This design is similar to the traditional ReAct framework, but more concise and direct. The framework provides two Agent types: CodeAgent and ToolCallingAgent. CodeAgent writes operations in Python code and supports multiple secure execution environments, including E2B, Blaxel, Modal, Docker and Pyodide+Deno WebAssembly. ToolCallingAgent is a traditional tool that calls Agent and generates actions in JSON or text format. This dual-track design allows developers to flexibly choose according to the scenario. Installing SmolAgents is very simple, just one line of command: `pip install "smolagents[toolkit]"`Creating the first Agent is equally simple. It only requires a few lines of Python code to create a fully functional agent. The framework also provides a wealth of preset tools, including web search tools, document retrieval tools, etc., developers can quickly build various application scenarios. SmolAgents adopts a code-first approach and has performed well in multiple benchmark tests. The core advantage lies in its execution efficiency - compared with traditional JSON format tool calls, generation Code execution can reduce the number of execution steps and LLM calls by about 30%. This improvement stems from the natural advantages of code: the code can naturally support function nesting and object reuse, while the JSON format requires complex parsing and processing. In the GAIA benchmark test, the performance of agents based on SmolAgents and open source models is particularly outstanding. The open source model combined with SmolAgents can achieve a performance level comparable to that of the closed source model, which marks a major breakthrough in the open source model's ability to handle complex tasks.

  • SmolAgents is an open source free framework that mainly makes money through Hugging Face's ecosystem. Developers can use the full functionality of the framework for free and share and obtain tools through the Hugging Face Hub. The charging model mainly includes Hugging Face’s paid model services, enterprise-level technical support, and cloud deployment services.

  • The developer community highly recognizes SmolAgents for its simple design. Many developers say the framework's ease of use is its greatest strength—it only takes a few lines of code to build a fully functional agent. The code-first approach has been well received, with developers finding it more intuitive and efficient. The outstanding performance of the open source model in the benchmark test has also triggered heated discussions in the community, and many people believe that this marks a major breakthrough for the open source model. Some developers expressed dissatisfaction with the limitations of the framework. The lack of multi-agent support is a major criticism, and many developers who need to build complex systems have to choose other frameworks. In addition, documentation and examples have been criticized for not being rich enough, and the learning curve for newbies is high. Insufficient enterprise-grade features are another frequently mentioned issue.

  • SmolAgents has established a unique market positioning in the field of AI Agent framework. Its core competencies lie in simplicity and transparency, making it suitable for developers who pursue rapid prototyping and code controllability. The open source nature of the framework has enabled it to gain extensive community support, and it also faces competition from mature frameworks such as LangChain and AutoGen. Judging from industry trends, the code-first Agent approach is gaining more and more attention. The success of SmolAgents proves the effectiveness of this approach and may lead to a new wave of framework design trends.

  • SmolAgents lacks multi-agent collaboration support and is not suitable for complex scenarios that require multi-agent collaboration. The framework does not support built-in memory functions, lacks persistent memory support, and needs to integrate external solutions. The competitive pressure of mature frameworks such as LangChain, AutoGen, and CrewAI is increasing day by day, and the enterprise-level functional ecosystem is relatively weak.

  • SmolAgents is suitable for developers who pursue rapid prototyping, technical teams that value code transparency and controllability, scholars and students studying Agent technology, developers using open source models, and individual users who need to automate simple tasks. The simple design of the framework makes it suitable for learning and experimental purposes. The following groups may not be suitable for using SmolAgents: teams that need to build multi-agent systems, enterprise applications that require complex workflow orchestration, teams that value production-grade tools and ecology, and applications that require persistent memory support. For these scenarios, it is recommended to choose LangChain, AutoGen or CrewAI.

  • SmolAgents, as a lightweight Agent framework launched by Hugging Face, excels in simplicity and efficiency. Its code-first design concept represents an important development direction of the Agent framework. The core idea of ​​the framework - thinking in code - is gaining more and more attention and recognition. For teams and individuals who pursue simplicity, transparency and efficient development, SmolAgents is an option worth considering.

User Reviews

  • 头像
    墨染103
    最近在做RAG项目,试了试SmolAgents,真的太香了!几百行代码就能跑起来,比LangChain轻量太多。

  • 头像
    Bobby.Morgan_7
    吹爆CodeAgent,用Python代码执行的方式比传统JSON Agent效率高30%不是吹的,实测确实香。

  • 头像
    TaylorBerg
    HF家的东西确实好用,生态完善,文档清晰,就是企业级功能还是欠缺一点点。

  • 头像
    BlocaDex
    免费开源还还要啥自行车,小型项目完全够用,大型项目建议上LangChain。

  • 头像
    Alan.Thompson_Max
    好奇害死猫。

  • 头像
    JoanMorris_2020
    装了试试,几行代码就跑起来了,文档也挺详细的,适合快速原型。

  • 头像
    Joan.Parker_724
    和AutoGen对比了下,SmolAgents更适合简单场景,复杂多Agent还是AutoGen更强。

  • 头像
    Carl332
    代码优先的方法确实更高效,减少了API调用次数,降本效果明显。

  • 头像
    Grace_JacksonSr86
    HF的东西确实对开发者友好,simplicity拉满。

  • 头像
    EvaReyes
    用了一下午,基础的搜索和API调用已经跑通了,就是缺少内置memory有点麻烦。

  • 头像
    ThomasGarcia_88
    支持本地的Transformers模型,对隐私敏感的项目很友好。

  • 头像
    Brandon_JamesSr
    用E2B沙箱执行代码,安全方面还算靠谱。

  • 头像
    MsCathrionaGrant_88
    支持Vision以后可以处理图片了,适用范围更广了。

  • 头像
    逍遥_12
    团队技术强,代码质量高,维护也及时,提issue很快就回了。

  • 头像
    松涛_9
    GitHub Star数涨得挺快的,社区在成长。

  • 头像
    SaraCampbell369062
    想问问怎么加自定义tool,有大佬知道吗?

  • 头像
    JocelynPerry
    适合学习Agent原理,代码少看得懂,生产用还是LangChain稳。

  • 头像
    Anna_Reed0070
    用了两个月,真香,但想搞复杂工作流时发现不支持有点难受。

  • 头像
    C_oinAnalystWalker
    支持100+LLM这点很爽,换模型很方便。

  • 头像
    Cynthia_RodriguezII
    CLI工具方便,快速测试很实用。