Why write actions as code instead of JSON?
Because programming languages express computer behavior better than message formats do. One generated block can hold a loop over search results or pass intermediate values between tools, work that plain tool calling must spread across many round trips with no shared state. Fewer model calls for the same task means less latency and fewer places to drift, which matters most when running capable open-weight models. The tradeoff is safety: generated code needs a sandboxed interpreter, making execution boundaries as important as content guardrails.
When is a minimal library the right choice?
For prototypes, education, and small agentic systems where you want to read every line running. It integrates tightly with the Hugging Face ecosystem while staying model-agnostic. Once a system needs durable state, retries across hours, or human checkpoints, that infrastructure belongs in a fuller agentic workflow runtime, and teams typically graduate to something like CrewAI or another orchestration layer rather than growing the thousand lines themselves. Pick smolagents when you want an agent small enough to fully understand.