# smolagents

> A barebones library for agents that think in code

Source: https://talira.ai/catalog/smolagents-61tg5g73
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library, Framework
- Categories: [ai / agents / frameworks](https://talira.ai/categories/ai/agents/frameworks), [languages / python](https://talira.ai/categories/languages/python)
- Licence: Apache-2.0[^1]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Self-hostable: yes[^2]
- Backed by: [Hugging Face](https://talira.ai/orgs/hugging-face.md)

smolagents is Hugging Face's minimal Python library for building agents, whose core logic fits in about 1,000 lines. Its CodeAgent writes its actions as Python code rather than JSON tool calls, and can run that code in sandboxes on Blaxel, E2B, Modal or Docker for safety; a ToolCallingAgent does classic tool calling. It works with any LLM (local transformers or Ollama models, Hugging Face inference providers, or OpenAI, Anthropic and others through LiteLLM), takes text, image, video and audio inputs, and uses tools from MCP servers, LangChain or Hugging Face Spaces. Agents and tools can be shared to and pulled from the Hugging Face Hub.

## Links

- Website: https://huggingface.co/docs/smolagents
- GitHub: https://github.com/huggingface/smolagents
- Docs: https://huggingface.co/docs/smolagents

## Problems it solves

- build an AI agent in a few lines of Python without a heavyweight framework
- let my agent write and run Python code as its actions instead of JSON tool calls
- run the code my agent writes in a sandbox so it can't damage my machine
- use tools from an MCP server or LangChain inside my own agent
- switch my agent between a local model and a hosted LLM without changing the code
- share an agent or a tool with others through the Hugging Face Hub
- build an agent that looks at screenshots or images while it works
- understand exactly what my agent framework does by reading its small source

## Features

- CodeAgent that writes its actions as Python code
- ToolCallingAgent for JSON tool calls
- sandboxed execution via Blaxel, E2B, Modal or Docker
- any LLM: transformers, Ollama, Hugging Face inference providers, LiteLLM
- tools from MCP servers, LangChain and Hugging Face Spaces
- share and load agents and tools on the Hugging Face Hub
- text, vision, video and audio inputs
- core agent logic in about 1,000 lines of code

## Trust

Overall: 0.27 out of 1.
Signals: backing 0.30, extensibility 0.00.

- backed by Hugging Face

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [Pydantic AI](https://talira.ai/catalog/pydantic-ai-qty4m7j7.md): How Python does AI: agents, realtime voice, image generation, embeddings, typed end to end
- [Mastra](https://talira.ai/catalog/mastra-2p2exeg9.md): The modern TypeScript framework for AI-powered applications and agents
- [LangGraph](https://talira.ai/catalog/langgraph-0wg8grbt.md): Low-level orchestration framework for building stateful agents
- [AgentScope](https://talira.ai/catalog/agentscope-2sc18s11.md): Build and run agents you can see, understand and trust
- [CAMEL](https://talira.ai/catalog/camel-gj2fcj9x.md): Open source multi-agent framework for finding the scaling laws of agents
- [Strands Agents](https://talira.ai/catalog/strands-agents-pztm3re2.md): Open source SDK for building and running production AI agents in Python and TypeScript

## Sources

[^1]: https://github.com/huggingface/smolagents/blob/main/LICENSE (checked 22 Nov 2026)
[^2]: https://github.com/huggingface/smolagents (checked 22 Nov 2026)
