Skip to main content

License Documentation GitHub release Contributor Covenant

🤗 smolagents - a smol library to build great agents!

smolagents is a library that enables you to run powerful agents in a few lines of code. It offers:

Simplicity: the logic for agents fits in ~thousand lines of code. We kept abstractions to their minimal shape above raw code!

🌐 Support for any LLM: it supports models hosted on the Hub loaded in their transformers version or through our inference API, but also models from OpenAI, Anthropic, and many more through our LiteLLM integration.

🧑‍💻 First-class support for Code Agents, i.e. agents that write their actions in code (as opposed to "agents being used to write code"), read more here.

🤗 Hub integrations: you can share and load tools to/from the Hub, and more is to come!

Quick demo

First install the package.

pip install smolagents

Then define your agent, give it the tools it needs and run it!

from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel

agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())

agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")

https://github.com/user-attachments/assets/cd0226e2-7479-4102-aea0-57c22ca47884

Code agents?

In our CodeAgent, the LLM engine writes its actions in code. This approach is demonstrated to work better than the current industry practice of letting the LLM output a dictionary of the tools it wants to calls: uses 30% fewer steps (thus 30% fewer LLM calls) and reaches higher performance on difficult benchmarks. Head to our high-level intro to agents to learn more on that.

Especially, since code execution can be a security concern (arbitrary code execution!), we provide options at runtime:

  • a secure python interpreter to run code more safely in your environment
  • a sandboxed environment using E2B.

How smol is it really?

We strived to keep abstractions to a strict minimum: the main code in agents.py is only ~1,000 lines of code. Still, we implement several types of agents: CodeAgent writes its actions as Python code snippets, and the more classic ToolCallingAgent leverages built-in tool calling methods.

By the way, why use a framework at all? Well, because a big part of this stuff is non-trivial. For instance, the code agent has to keep a consistent format for code throughout its system prompt, its parser, the execution. So our framework handles this complexity for you. But of course we still encourage you to hack into the source code and use only the bits that you need, to the exclusion of everything else!

Citing smolagents

If you use smolagents in your publication, please cite it by using the following BibTeX entry.

@Misc{smolagents,
  title =        {`smolagents`: The easiest way to build efficient agentic systems.},
  author =       {Aymeric Roucher and Thomas Wolf and Leandro von Werra and Erik Kaunismäki},
  howpublished = {\url{https://github.com/huggingface/smolagents}},
  year =         {2025}
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smolagents-0.1.3.tar.gz (76.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smolagents-0.1.3-py3-none-any.whl (66.7 kB view details)

Uploaded Python 3

File details

Details for the file smolagents-0.1.3.tar.gz.

File metadata

  • Download URL: smolagents-0.1.3.tar.gz
  • Upload date:
  • Size: 76.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.0

File hashes

Hashes for smolagents-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7eba654d783af36aa187bb21279ad5926e59a2c58e612a0f4b6aba906c700bc6
MD5 3ad32cd9a5bd2b641263e83a2a890b86
BLAKE2b-256 bd34f914e45669f0ef93acb9c34f06a0847b802394db8afc3251af5961c05737

See more details on using hashes here.

File details

Details for the file smolagents-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: smolagents-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 66.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.0

File hashes

Hashes for smolagents-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d3d40b773360b5251a8c8851b4ce0ffd5df3a2215595698f113da57f3f3d859c
MD5 28c769d68b9bc81c109fa07b1783b859
BLAKE2b-256 cdfed4d60ed91e122f92e7fa04b3a2d1b7c52e7ec73f01452abef8a132e4a888

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page