---
title: "Introducing smolagents: simple agents that write actions in code."
description: "smolagents is a minimal Python library from Hugging Face for building LLM agents, with first-class support for code agents that write their actions as Python code instead of JSON tool calls."
url: "https://swe.quest/articles/introducing-smolagents-simple-agents-that-write-actions-in-code-081cf3257f37300e"
canonical: "https://huggingface.co/blog/smolagents"
source: "Hugging Face"
published: "2024-12-31"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 11
tags: ["ai-agents","llms","python","open-source"]
---

# Introducing smolagents: simple agents that write actions in code.

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-12-31, 11 min read, Announcement. Original: [https://huggingface.co/blog/smolagents](https://huggingface.co/blog/smolagents)

## Summary

smolagents is a minimal Python library from Hugging Face for building LLM agents, with first-class support for code agents that write their actions as Python code instead of JSON tool calls. Agency is framed as a spectrum from simple output processing to multi-step and multi-agent loops, and the post advises using deterministic workflows unless tasks genuinely need flexibility. Code actions are argued to beat JSON for composability, object handling, generality and training-data coverage. The library supports sandboxed execution via E2B, custom tools defined with a @tool decorator and shareable on the Hub, any LLM via transformers, the HF inference API or LiteLLM, and a benchmark shows open models competitive with closed ones on agentic tasks.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Open source](https://swe.quest/tags/open-source.md) (Engineering practices)

## Prerequisites

- Python ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- LLM tool calling basics ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))

## Keywords

smolagents, Hugging Face, CodeAgent, E2B, LiteLLM, transformers.agents

## Related posts

- [Open-source DeepResearch – Freeing our search agents](https://swe.quest/articles/open-source-deepresearch-freeing-our-search-agents-72a8cc1624888c05.md): Hugging Face · 2025-02-04 · Medium · 17 min read · AI agents, LLMs, Evaluation, Open source
  Hugging Face reproduced OpenAI's Deep Research agent in about 24 hours using the open smolagents framework and reached 55.15% on the GAIA validation set, up from roughly 46% for the previous open state of the art (Magentic-One).
- [Introducing Agents.js: Give tools to your LLMs using JavaScript](https://swe.quest/articles/introducing-agents-js-give-tools-to-your-llms-using-javascript-690428d96ad96e44.md): Hugging Face · 2023-07-24 · Medium · 4 min read · AI agents, JavaScript, LLMs
  Agents.js is a JavaScript library from huggingface.js that gives LLMs tool access in the browser or on Node.
- [CodeAgents + Structure: A Better Way to Execute Actions](https://swe.quest/articles/codeagents-structure-a-better-way-to-execute-actions-5f9ad7c5f62e107c.md): Hugging Face · 2025-05-28 · Medium · 8 min read · AI agents, LLMs, Evaluation, Python
  Forcing code-writing agents to emit their reasoning and Python code as a structured JSON blob (thoughts + code) beats both markdown-parsed CodeAgents and JSON tool-calling agents by 2-7 percentage points on GAIA, MATH, SimpleQA and Frames for capable models.
- [Open SWE: An Open-Source Framework for Internal Coding Agents](https://swe.quest/articles/open-swe-an-open-source-framework-for-internal-coding-agents-1b0f7521a5a00040.md): LangChain · 2026-10-13 · Medium · 8 min read · AI agents, AI for coding, Open source, Sandboxing & isolation
  Open SWE is an MIT-licensed framework for internal coding agents, built on Deep Agents and LangGraph.
- [CoderForge-Preview: SOTA open dataset for training efficient coding agents](https://swe.quest/articles/coderforge-preview-sota-open-dataset-for-training-efficient-coding-agents-83e1f3c7a7bdb67a.md): Together AI · 2026-02-25 · Hard · 14 min read · Model training, AI for coding, AI agents, Evaluation, LLMs
  CoderForge-Preview is an open dataset of 258K test-verified coding agent trajectories (155K passing) covering 51K tasks across 1,655 repositories from R2E-Gym, SWE-Smith and SWE-Rebench.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
