← hub

smolagents Architecture

Code-first agent framework from HuggingFace (~1K-line core; ~13K total repo) · v1.26.0 (2026-05-29)

Core Insight: Code as Tool Invocation

Instead of JSON tool schemas and message passing, the LLM writes and executes Python code directly. Tools become Python functions. No schema translation, no parsing layers, no abstraction tax.

# Traditional agent (JSON tool calls)
{"tool": "search", "args": {"query": "latest news"}}
{"tool": "summarize", "args": {"text": "..."}}

# smolagents (Python code)
results = search("latest news")
summary = summarize(results["text"][:1000])
final_answer(summary)