smolagents
Use Hugging Face Smolagents framework for code-based agentic research with tool support. Supports multiple LLM providers and web search.
Best use case
smolagents is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use Hugging Face Smolagents framework for code-based agentic research with tool support. Supports multiple LLM providers and web search.
Teams using smolagents should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/smolagents/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How smolagents Compares
| Feature / Agent | smolagents | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use Hugging Face Smolagents framework for code-based agentic research with tool support. Supports multiple LLM providers and web search.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# Smolagents Skill
This skill leverages Hugging Face's Smolagents framework, a minimalist AI agent library where agents write Python code to accomplish tasks. It's highly efficient (30% token efficiency gain) and supports multiple LLM providers.
## Setup
1. **Dependencies:** Requires `smolagents` with toolkit extensions.
```bash
pip install 'smolagents[toolkit]' python-dotenv
```
2. **API Key Configuration:** Supports multiple LLM providers. At minimum, set one:
```bash
# For Hugging Face Inference API (default, free tier available)
echo "HF_TOKEN=your_huggingface_token" >> .env
# OR for OpenAI
echo "OPENAI_API_KEY=your_openai_key" >> .env
# OR for Anthropic
echo "ANTHROPIC_API_KEY=your_anthropic_key" >> .env
if [ -f .gitignore ] && ! grep -q ".env" .gitignore; then echo ".env" >> .gitignore; fi
```
## Usage
Use the `scripts/agent.py` script to run research tasks.
### Command
```bash
python3 scripts/agent.py --task "<task_description>" [--model <model_type>] [--model-id <model_name>] [--web-search]
```
### Parameters
* `--task` (Required): The task or research question.
* `--model` (Optional): Model type - `hf` (Hugging Face), `openai`, `anthropic`, or `local` (default: `hf`).
* `--model-id` (Optional): Specific model ID to use.
* `--web-search` (Optional): Enable web search tool (uses DuckDuckGo).
* `--verbose` (Optional): Show detailed execution logs.
### Example
```bash
# Using Hugging Face Inference API with web search
python3 scripts/agent.py --task "Research the latest developments in transformer architecture improvements" --web-search --verbose
# Using a specific model
python3 scripts/agent.py --task "Analyze the impact of RLHF on LLM performance" --model hf --model-id "Qwen/Qwen2.5-72B-Instruct" --web-search
```
## Output
The script outputs:
* Generated Python code (to stderr for visibility)
* Task execution results
* Final answer or research findings
## Features
* **Code-as-Action**: Agents write and execute Python code to solve tasks
* **Tool Support**: Web search, file operations, and custom tools
* **Multi-Model**: Supports HF Inference API, OpenAI, Anthropic, local models
* **Efficient**: 30% token efficiency improvement over traditional approachesRelated Skills
xai-grok
Use xAI Grok API with Agent Tools for real-time web and X (Twitter) search and synthesis. Requires XAI_API_KEY.
tavily-search
Use Tavily Search API for optimized, real-time web search results for RAG. Requires TAVILY_API_KEY.
stanford-storm
Run Stanford STORM (knowledge-storm) to generate comprehensive, Wikipedia-style articles with citations. Requires LLM and Search API keys (Bing or You.com).
perplexity-sonar
Use Perplexity Sonar API for real-time, citation-backed answers. Ideal for up-to-date information and quick synthesis. Requires PERPLEXITY_API_KEY
openai-deep-research
Use OpenAI's Deep Research API (o3 / o4 models) to automate multi-step, citation-backed research workflows.
langchain-deep-research
Run LangChain Open Deep Research agent for iterative web research and comprehensive reports. Requires LLM API keys and search API (e.g., OPENAI_API_KEY, TAVILY_API_KEY).
jina-ai
Use Jina AI APIs for converting URLs to LLM-friendly Markdown (Reader) and searching the web (Search).
gpt-researcher
Run the GPT Researcher autonomous agent to generate comprehensive deep research reports. Requires LLM and Search API keys (e.g., OPENAI_API_KEY, TAVILY_API_KEY).
exa-research
Use Exa AI for neural search, content retrieval, and automated deep research. Requires EXA_API_KEY.
smolagents
You are an expert in smolagents, Hugging Face's minimalist agent framework. You help developers build AI agents that write and execute Python code to solve tasks, use tools from the Hugging Face Hub, chain multiple agents together, and run on any LLM (OpenAI, Anthropic, local models) — providing a simple, code-first approach to building agents without complex abstractions.
smolagents — Hugging Face Lightweight Agent Framework
You are an expert in smolagents, Hugging Face's minimalist agent framework. You help developers build AI agents that write and execute Python code to solve tasks, use tools from the Hugging Face Hub, chain multiple agents together, and run on any LLM (OpenAI, Anthropic, local models) — providing a simple, code-first approach to building agents without complex abstractions.
workspace-surface-audit
Audit the active repo, MCP servers, plugins, connectors, env surfaces, and harness setup, then recommend the highest-value ECC-native skills, hooks, agents, and operator workflows. Use when the user wants help setting up Claude Code or understanding what capabilities are actually available in their environment.