AGENT SKILL

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

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.md for CodeAgent, ToolCallingAgent, MultiStepAgent, planning, memory, callbacks, managed agents, serialization, streaming, final-answer checks, and run debugging.
  • Use sub-skills/tools-and-integrations/SKILL.md for Tool subclasses, @tool, schemas, validation, built-in tools, Hub/Space/LangChain/MCP integrations, and tool troubleshooting.
  • Use sub-skills/model-providers/SKILL.md for InferenceClientModel, LiteLLMModel, OpenAIModel, Azure, Bedrock, Transformers, MLX, vLLM, custom Model subclasses, credentials, and provider-specific errors.
  • Use sub-skills/execution-and-safety/SKILL.md for executor_type, LocalPythonExecutor, authorized imports, PythonInterpreterTool, Docker/E2B/Modal/Blaxel execution, sandboxing, and secure-code troubleshooting.
  • Use sub-skills/cli-and-ui/SKILL.md for smolagent, webagent, interactive mode, CLI model/tool flags, GradioUI, launch_gradio_demo, server patterns, and browser UI failures.

Common Decisions

  • Prefer CodeAgent when the model should write Python actions and maintain state through a Python executor.
  • Prefer ToolCallingAgent when the model natively emits tool calls and you need structured tool invocation or parallel tool calls.
  • Start with hosted InferenceClientModel for the smallest setup; switch to OpenAIModel, LiteLLMModel, or local wrappers only when the deployment requires it.
  • Keep additional_authorized_imports narrow; 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.md for package extras, optional dependencies, CLI availability, and verification commands.
  • Read references/troubleshooting.md for cross-cutting install/import, credential, optional dependency, CLI/API misuse, and workflow-routing failures.
  • Read references/repo-provenance.md when deciding whether this skill is stale relative to a newer smolagents checkout.

Shared Scripts

  • Run python scripts/smoke_smolagents_install.py --help to see the safe checks.
  • Run python scripts/smoke_smolagents_install.py after installation to verify import metadata, core constructors, and smolagent --help without calling external providers.
  • Add --check-webagent only when the vision extra is expected; failure usually means helium/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

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351