Jahanzaib
Production

Smolagents

Hugging Face's lightweight agent framework, focused on minimal code overhead and code-as-action agents that write Python to solve tasks.

Last updated: April 26, 2026

Definition

Smolagents is Hugging Face's minimalist agent framework, released in late 2024. The differentiator: instead of agents emitting JSON tool calls, smolagents agents write actual Python code that calls tools as functions, which the framework executes in a sandboxed environment. This pattern (called CodeAct) often produces better multi-step plans than JSON tool calling because the model is reasoning in the same language it was trained on most heavily. The framework is small (a few hundred lines of core code), works with any Hugging Face Hub model, and supports both vision-language and text-only agents.

When To Use

Try smolagents when you want code-as-action over JSON tool calls (often better for math, data wrangling, multi-step reasoning), or when you need a lightweight framework that does not impose much structure.

Sources

Related Terms

Building with Smolagents?

I've shipped this pattern in real production systems. If you want a second pair of eyes on your architecture, that's what I do.