Skip to content

Agent Framework

huggingface/smolagents

huggingface/smolagents· Python

Minimal Python agent framework where the LLM writes and executes code as its action space.

GitHub stats

Stars
26,982
Forks
2,536
Watchers
131
Open issues
525

meta

License
Apache-2.0
Primary language
Python
Last commit
2026-04-24
Stats fetched at
2026-04-29

HuggingFace's lightweight agent library built around the "code agent" idea: instead of emitting JSON tool calls, the LLM writes a Python snippet that calls your tools directly, runs in a sandbox (local or E2B), and feeds results back. Ships with `CodeAgent` and `ToolCallingAgent`, works with HF Inference, Transformers, Ollama, LiteLLM, and any OpenAI-compatible endpoint. Install via `pip install smolagents`. Targets builders who want a small, hackable core they can read end-to-end.

Editor's verdict

Pick this when you want a small, transparent agent loop you can fork in an afternoon, or when you're running local/open-weight models — code-as-action measurably reduces the tool-calling brittleness that hurts smaller LLMs. The trade-off: you must trust (or sandbox) generated Python, and the ecosystem around it is thin compared to LangGraph. Skip it if you need durable execution, complex multi-agent orchestration, or built-in observability — reach for LangGraph or Pydantic AI instead.

Last updated: 2026-04-29

We use cookies

Anonymous analytics help us improve the site. You can opt out anytime. Learn more