This is an early release preview. You may encounter bugs.
Smolagents logo
Unclaimed

Framework coding

Smolagents

Hugging Face library for agents that write their actions as Python code, with sandboxed execution

Built by Hugging Face

A 80/100 GitHub score ? This grade is derived from GitHub signals, not user votes. Open for the full breakdown.
No votes yet

01 / About

What Smolagents is.

smolagents is a Hugging Face library for building agents whose core logic fits in roughly 1,000 lines of code. Its distinguishing agent type, CodeAgent, follows a ReAct-style loop but writes each action as a Python code snippet rather than a JSON tool-call blob, so several tool calls can be combined in one step. Cited results report that code actions use about 30% fewer steps than JSON tool calling and score higher on difficult benchmarks. A conventional ToolCallingAgent that emits JSON actions is also available.

Because agent-written code is executed, the library provides sandboxed execution through E2B, Blaxel, Modal, or Docker; the built-in LocalPythonExecutor applies restrictions but is not a security boundary. Models are pluggable: InferenceClientModel routes to Hugging Face inference providers, LiteLLMModel covers 100+ hosted models, OpenAIModel targets any OpenAI-compatible server, and TransformersModel, AzureOpenAIModel, and AmazonBedrockModel cover local and cloud alternatives.

Tools can come from MCP servers, LangChain, or Hugging Face Spaces, and agents and tools can be pushed to or pulled from the Hub. Agents accept text, vision, video, and audio inputs, and multi-agent hierarchies are supported. Two CLI entry points exist: smolagent runs a multi-step CodeAgent with an interactive setup wizard, and webagent drives a browser through helium.

Features

  • CodeAgent: writes actions as Python snippets executed in a ReAct loop until final_answer is called
  • ToolCallingAgent: standard JSON tool-calling alternative
  • Sandboxed execution: E2B, Blaxel, Modal, or Docker isolate agent-generated code
  • Model classes: InferenceClientModel, LiteLLMModel, OpenAIModel, TransformersModel, AzureOpenAIModel, and AmazonBedrockModel
  • Tool sources: MCP servers, LangChain tools, Hub Spaces, and a default toolkit including WebSearchTool
  • Hub integration: pushtohub and from_hub share agents and tools as Hub repositories
  • Multimodal inputs: text, vision, video, and audio
  • Multi-agent hierarchies: agents can manage other agents
  • CLI: smolagent for general tasks and webagent for browser automation
  • Benchmarking: an included benchmark script compares open and closed models as code agents

02 / Discussion CREDIBILITY-GATED

Discussion

Reading is open to everyone. Posting and voting need a verified identity or a GitHub grade of B or higher.

  • No discussions yet.

04 / Build

Build with Smolagents.

Browse the catalogue for frameworks, tools, and harnesses, each scored on real GitHub credibility.

Get Smolagents →

Browse the catalogue