Hugging Face releases smolagents with code-as-action architecture

Hugging Face released smolagents in December 2024 with a structural departure from the dominant approach to AI agent design. Where most frameworks had agents emit JSON tool-call objects — structured payloads that the framework then translated into actions — smolagents’ CodeAgent had the model write actual Python code as each action step. The code ran in a sandbox, output fed back into the next reasoning step, and the agent continued until the task was complete.

This code-as-action design produced measurably more efficient agents: benchmark testing showed 30% fewer execution steps compared to dictionary-based tool calling, while achieving higher performance on coding and data manipulation tasks. The intuition was that Python is a richer action language than JSON — it supports arbitrary computation, flow control, and composition within a single step rather than requiring multiple sequential tool calls.

The framework’s minimal core — approximately 1,000 lines of code — made it unusually transparent and auditable. Hugging Face built in Model Context Protocol (MCP) support, connecting agents to the growing ecosystem of MCP tool servers. smolagents reached 27,800 GitHub stars by June 2026, with v1.26.0 released May 29, 2026 confirming active Hugging Face backing. The framework’s approach influenced subsequent agent designs that prioritised code generation as a first-class action primitive.

Sources

Last verified June 12, 2026