Content
summary Summary

Hugging Face just released "smolagents," a stripped-down open-source library that lets developers create AI agents with minimal code.

Ad

The library itself is remarkably lightweight, containing just about a thousand lines of code and keeping things as simple as possible. While the design is intentionally minimal, Hugging Face says it still handles all the complex parts of building AI agents.

After installing it through pip (Python's package manager), you can get an agent up and running with just a few lines of code. In their demo, they show an agent using DuckDuckGo to answer complex questions.

Smolagents in action. | Video: Hugging Face

Ad
Ad

The heart of smolagents is the so-called CodeAgent. Instead of following the usual industry practice where AI models output a dictionary of tools to call, CodeAgent lets the AI write Python code directly.

According to Hugging Face, this approach reduces the number of steps by 30 percent and requires fewer AI calls, while still performing better on benchmarks. For those who prefer the traditional approach, there's also a ToolCallingAgent that uses standard tool calling methods.

Flexibility and Security

Smolagents works with a wide range of language models, including those from OpenAI and Anthropic, as well as models hosted on Hugging Face Hub. Developers can connect to these models through the Hub's Transformers library, the HF Inference API, or LiteLLM.

Since letting AI agents generate and run code can be risky, smolagents comes with several security features. Developers can choose between a secure Python interpreter for local execution or use a sandboxed environment with E2B.

The platform also lets users share and load tools through the Hugging Face Hub, with more hub features planned for the future. The entire Smolagents project is available on GitHub. Smolagents joins a growing field of AI agent frameworks, with OpenAI, Microsoft, and AWS all releasing their own takes recently.

Ad
Ad
Join our community
Join the DECODER community on Discord, Reddit or Twitter - we can't wait to meet you.
Recommendation
Support our independent, free-access reporting. Any contribution helps and secures our future. Support now:
Bank transfer
Summary
  • Hugging Face has released "smolagents," an open-source library that simplifies the creation of powerful AI agents, requiring only a few lines of code from developers.
  • The library's main feature, CodeAgent, allows the AI to write its actions directly in Python code, resulting in 30% fewer work steps, reduced AI calls, and improved performance on challenging benchmarks.
  • "Smolagents" is compatible with various language models and includes security features such as a secure Python interpreter for local execution and a sandboxed environment using E2B.
Sources
Online journalist Matthias is the co-founder and publisher of THE DECODER. He believes that artificial intelligence will fundamentally change the relationship between humans and computers.
Join our community
Join the DECODER community on Discord, Reddit or Twitter - we can't wait to meet you.