← All frameworks

smolagents

A tiny agent library that writes Python.

Autonomous

Hugging Face's answer to framework bloat. The core is about a thousand lines, and its trick is that the agent writes Python code to act rather than emitting JSON tool calls, which turns out to need fewer steps.

Reach for it when

  • You want to read the whole framework in an afternoon
  • You like the idea of agents that write code
  • You are already in the Hugging Face ecosystem

Look elsewhere when

  • You need enterprise features like tracing and approval gates
  • Letting an agent run generated code is not acceptable

What the lessons will cover

  1. 01Install and setup
  2. 02CodeAgent and ToolCallingAgent
  3. 03Tools
  4. 04Sandboxed execution
  5. 05Models and providers
  6. 06Multi agent
  7. 07Sharing to the Hub
  8. 08A working agent

Others in autonomous

Common questions

Is smolagents free to use?

smolagents is open source and free to run yourself. You still pay whichever model provider you point it at, and this tutorial is free with no signup.

Do I need to know Python to use smolagents?

Basic Python is enough. Functions, dictionaries and imports cover most of what smolagents asks of you.

When should I not use smolagents?

You need enterprise features like tracing and approval gates. Letting an agent run generated code is not acceptable.

Lessons for smolagents are being written. Meanwhile the LangGraph tutorial covers the same ground: state, tools, loops, memory and human approval. Most of it carries straight over.

Start the LangGraph tutorial →