Hugging Face releases smolagents: CodeAgent paradigm allows Agent to call tools in the form of code, supporting MCP and sandbox isolation

Hugging Face launched the lightweight Agent library smolagents, which takes the CodeAgent paradigm as the core and natively supports MCP tools, E2B sandbox isolation and HF Hub model sharing, emphasizing minimalist abstraction and fast access.

smolagents releases the latest capability updates to enhance enterprise implementation efficiency

Hugging Face launches smolagents, an open source Python Agent library with a minimalist design and a core code of about 1,000 lines. The biggest feature is that CodeAgent is used as a first-class citizen paradigm: Agent is not called through JSON description tools, but directly writes Python code to organize the control flow, and naturally supports function nesting, loops and conditional logic.

CodeAgent vs ToolCallingAgent

CodeAgent (recommended by default): Agent writes operations as Python code for execution, and tool calls are implemented through code combination. Suitable for complex logical task links.

ToolCallingAgent: Supports the traditional JSON/text tool calling paradigm and is compatible with mainstream tool description formats. Suitable for tool interface standardization scenarios.

Safe execution: built-in sandbox isolation support

CodeAgent execution requires security isolation, and smolagents natively connects to multiple sandbox solutions:

  • E2B — Firecracker microVM isolation sandbox
  • Modal — Serverless computing platform
  • Docker — local isolation
  • Blaxel — Cloud Agent runtime

Model independent × Tool independent

Supported models: HF Inference API, OpenAI, Anthropic, LiteLLM, native Transformers / Ollama.

Supported tools: MCP Server (native support), LangChain tool, HF Hub Space tool, custom Python function.

Quick installation

pip install 'smolagents[toolkit]'
from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool
model = InferenceClientModel()
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
result = agent.run("What are the major developments in AI Agent in the past week?")

HF Hub ecological integration

Smolagents supports uploading Agents and tools to HF Hub in the form of Gradio Space, and can also directly load Agent configurations shared by the community from the Hub. It is currently a rare Agent framework with the capability of "community asset sharing".

Official documentation: https://huggingface.co/docs/smolagents | Installation: pip install smolagents

Copyright: Content sourced from smolagents official . This platform has compiled and organized this content for informational purposes and learning exchange only. If there are any copyright concerns, please contact us for resolution.

Reviews

  • Loading reviews...