smolagents homepage

smolagents

by Hugging Face

Minimalist open-source library for agents that think in code

FrameworkSupervised

Last reviewed 2026-06-18

smolagents is Hugging Face's open-source library for building agents in a few lines of code, with the core agent logic deliberately kept under roughly 1,000 lines. Its signature idea is the CodeAgent, which writes its actions as Python code snippets rather than JSON tool calls, enabling natural composability (loops, conditionals, nested calls); it also offers a more classic ToolCallingAgent. Code actions can run in sandboxed environments via E2B, Modal, Docker, or Blaxel. It is model-agnostic, working with local transformers or Ollama models, any model on the Hugging Face Hub, or OpenAI, Anthropic, and others via LiteLLM, and supports text, vision, video, and audio inputs. As a framework, the autonomy of what you build is developer-defined; it targets developers who want a small, transparent agent library with Hub integration for sharing tools and agents.

What it can do

  • Run code-writing agents (CodeAgent)

    Supervised

    CodeAgent writes its actions as Python code snippets to invoke tools and compute, enabling loops, conditionals, and nested calls; a ToolCallingAgent uses classic tool calling.

    source
  • Execute actions in sandboxes

    Supervised

    Runs generated code in sandboxed environments via E2B, Modal, Docker, or Blaxel for safer execution.

    source
  • Run any model and multimodal inputs

    Supervised

    Works with local transformers/Ollama models, Hub models, or OpenAI/Anthropic via LiteLLM, and supports text, vision, video, and audio inputs.

    source
  • Share tools and agents via the Hub

    Assistant

    Push and pull tools and agents to and from the Hugging Face Hub for sharing.

    source

Strengths

  • +Tiny, transparent core (~1,000 lines) that is easy to read and extend
  • +Code-as-action approach enables natural composability
  • +Model-agnostic, multimodal, with sandboxed execution and Hub sharing

Limitations

  • Minimalist by design: fewer batteries-included features than larger frameworks
  • A framework, not a product: you build, host, and secure agents yourself
  • Code execution requires sandboxing to be safe; autonomy is developer-defined

Overview

smolagents is Hugging Face's minimalist open-source library for building agents, with the core logic deliberately kept under roughly 1,000 lines.

What it does

Its signature is the CodeAgent, which writes actions as Python code snippets (rather than JSON tool calls), enabling natural composability via loops, conditionals, and nested calls; a ToolCallingAgent uses classic tool calling. Code actions run in sandboxes via E2B, Modal, Docker, or Blaxel. It is model-agnostic and multimodal (text, vision, video, audio), and integrates with the Hugging Face Hub for sharing tools and agents.

Autonomy note

This is a developer framework, not an end-user agent. How autonomously a built agent acts depends on the tools, sandboxing, and approvals the developer configures; we list it as supervised-agent conservatively.

Integrations & setup

Installed as a Python library. Works with Hub models, local models, or providers via LiteLLM, supports MCP, and relies on external sandboxes for safe code execution.

Pricing

Free and open source; you pay for model and sandbox usage.

Best for / not for

Best for developers who want a small, transparent, hackable agent library with the code-as-action pattern. Less suited to those who want extensive built-in integrations or a no-code platform.

Alternatives

LangChain, CrewAI, AutoGen, the OpenAI Agents SDK, and Pydantic AI are competing frameworks.

What people are saying

We aggregate real LinkedIn discussion into sentiment for the agents people search most. smolagents isn't tracked yet, want it added? Request tracking.

FAQ

What is a CodeAgent?+

A smolagents agent that writes its actions as executable Python code snippets rather than JSON tool calls, which enables loops, conditionals, and nested calls. Code runs in a sandbox for safety.

Which models does smolagents support?+

It is model-agnostic: local transformers or Ollama models, any model on the Hugging Face Hub, or OpenAI, Anthropic, and others via LiteLLM.

Sources

Last reviewed 2026-06-18

Alternatives & related