smolagents

A minimal Python library from Hugging Face for building AI agents that write and run code to solve tasks. It lets you set up capable agents in a few lines.

Share on XLicense: Apache-2.0

Overview

smolagents is a small Python library from Hugging Face for building AI agents that think in code. Its CodeAgent writes its actions as code instead of structured tool calls. The agent logic fits in about 1,000 lines. It works with any model, including local transformers or Ollama models and providers reached through LiteLLM. Generated code can run in sandboxes such as Blaxel, E2B, Modal or Docker.

Key features

  • CodeAgent that writes its actions as Python code
  • Model-agnostic, from local models to hosted providers
  • Tools from MCP servers, LangChain or Hub Spaces
  • Sandboxed execution through Blaxel, E2B, Modal or Docker
  • Share and pull tools or agents on the Hugging Face Hub

Best for

Developers who want a compact, readable agent framework and are happy to let the model write code. Running generated code safely calls for one of the supported sandboxes.

Upstream
huggingface/smolagents
Fork on GitHub
Guo-astro/smolagents
Upstream stars
30k
Category
AI agents and LLM tools
License
Apache-2.0
Forked
2026-09-28
Sync status
In syncLast synced 2026-09-29