smolagents
Build, debug, and operate Hugging Face smolagents agents, tools, model providers, secure executors, CLIs, and UI workflows with self-contained references and helpers.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- smolagents
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Build, debug, and operate Hugging Face smolagents agents, tools, model providers, secure executors, CLIs, and UI workflows with self-contained references and helpers.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/install-and-extras.md2.9 KB
- 参考文档references/repo-provenance.md2.8 KB
- 参考文档references/repo-routing-metadata.json498 B
- 参考文档references/troubleshooting.md3.6 KB
- 脚本scripts/smoke_smolagents_install.py3.8 KB
03 SKILL.md 正文
smolagents
Use this skill when working with Hugging Face smolagents: code-writing agents, tool-calling agents, custom tools, model provider wrappers, secure Python execution, command-line entry points, or Gradio/browser UI workflows.
Quick Start
Install only the extras needed for the route you are using:
pip install smolagents
pip install "smolagents[toolkit]" # web search and webpage tools
pip install "smolagents[openai]" # OpenAI-compatible client support
pip install "smolagents[litellm]" # LiteLLM provider routing
pip install "smolagents[gradio]" # Gradio UI helpers
pip install "smolagents[vision]" # webagent browser automation stack
Minimal import and agent shape:
from smolagents import CodeAgent, InferenceClientModel
model = InferenceClientModel()
agent = CodeAgent(tools=[], model=model)
result = agent.run("Summarize the task and return final_answer.")
Route by Task
- Use
sub-skills/agent-workflows/SKILL.mdforCodeAgent,ToolCallingAgent,MultiStepAgent, planning, memory, callbacks, managed agents, serialization, streaming, final-answer checks, and run debugging. - Use
sub-skills/tools-and-integrations/SKILL.mdforToolsubclasses,@tool, schemas, validation, built-in tools, Hub/Space/LangChain/MCP integrations, and tool troubleshooting. - Use
sub-skills/model-providers/SKILL.mdforInferenceClientModel,LiteLLMModel,OpenAIModel, Azure, Bedrock, Transformers, MLX, vLLM, customModelsubclasses, credentials, and provider-specific errors. - Use
sub-skills/execution-and-safety/SKILL.mdforexecutor_type,LocalPythonExecutor, authorized imports,PythonInterpreterTool, Docker/E2B/Modal/Blaxel execution, sandboxing, and secure-code troubleshooting. - Use
sub-skills/cli-and-ui/SKILL.mdforsmolagent,webagent, interactive mode, CLI model/tool flags,GradioUI,launch_gradio_demo, server patterns, and browser UI failures.
Common Decisions
- Prefer
CodeAgentwhen the model should write Python actions and maintain state through a Python executor. - Prefer
ToolCallingAgentwhen the model natively emits tool calls and you need structured tool invocation or parallel tool calls. - Start with hosted
InferenceClientModelfor the smallest setup; switch toOpenAIModel,LiteLLMModel, or local wrappers only when the deployment requires it. - Keep
additional_authorized_importsnarrow; route broad filesystem, network, browser, or service tasks through the execution-and-safety guidance before enabling imports or remote executors. - Validate tools and model configuration locally before running live providers, browsers, Hub operations, or remote executors.
Shared References
- Read
references/install-and-extras.mdfor package extras, optional dependencies, CLI availability, and verification commands. - Read
references/troubleshooting.mdfor cross-cutting install/import, credential, optional dependency, CLI/API misuse, and workflow-routing failures. - Read
references/repo-provenance.mdwhen deciding whether this skill is stale relative to a newer smolagents checkout.
Shared Scripts
- Run
python scripts/smoke_smolagents_install.py --helpto see the safe checks. - Run
python scripts/smoke_smolagents_install.pyafter installation to verify import metadata, core constructors, andsmolagent --helpwithout calling external providers. - Add
--check-webagentonly when thevisionextra is expected; failure usually meanshelium/browser dependencies are missing.
Guardrails
- Do not hardcode API keys in examples, serialized tools, CLI invocations, or config files; read them from environment variables or secret managers.
- Do not install
smolagents[all]by default; choose the narrow extra for the selected provider, tool, UI, or executor. - Do not instruct users to run original repository examples or tests from this skill. Use the bundled references and scripts here as the reusable runtime source.
- Treat network, browser automation, remote sandboxes, Hub pushes, and model calls as opt-in operations requiring credentials, services, or optional packages.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).