tools-and-integrations
Use this sub-skill when defining, validating, sharing, loading, or troubleshooting smolagents tools, built-in/default tools, Hub/Space/LangChain integrations, or MCP tool collections.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- tools-and-integrations
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use this sub-skill when defining, validating, sharing, loading, or troubleshooting smolagents tools, built-in/default tools, Hub/Space/LangChain integrations, or MCP tool collections.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md6.7 KB
- 参考文档references/built-in-tools.md4.5 KB
- 参考文档references/troubleshooting.md6.6 KB
- 参考文档references/workflows.md7.8 KB
- 脚本scripts/validate_tool_schema.py6.9 KB
03 SKILL.md 正文
Tools and Integrations
Use This For
- Creating a smolagents tool with a
Toolsubclass or the@tooldecorator. - Designing
inputs,output_type, optionaloutput_schema, and runtime argument validation. - Adding built-in tools such as
DuckDuckGoSearchTool,VisitWebpageTool,UserInputTool, orFinalAnswerToolto an agent. - Loading tools from Hub Spaces/collections, Gradio apps, LangChain tools, or MCP servers.
- Diagnosing schema, serialization, optional dependency, trust, network, and name-collision failures.
Route Elsewhere
- Agent selection, managed agents, planning, callbacks,
max_steps, or toolbox composition strategy across agents: use../agent-workflows/SKILL.md. - Model classes, provider credentials, model routing, structured model output behavior, or LiteLLM setup: use
../model-providers/SKILL.md. smolagent,webagent, Gradio UI, CLI commands, and app launching: use../cli-and-ui/SKILL.md.- Code execution sandboxes, executor backends, authorized imports, and secure execution policy: use
../execution-and-safety/SKILL.md.
Fast Path
- Choose
@toolfor a simple stateless function; choose aToolsubclass when you need class attributes,setup(), helper methods, lazy model/client initialization, or serialization control. - Keep tool names valid Python identifiers and unique inside an agent toolbox;
agent.toolsis a dict keyed bytool.name. - Validate schema shape before wiring a tool into an agent:
python scripts/validate_tool_schema.py path/to/tool_file.py --object tool_or_class_name. - For remote or third-party integrations, require explicit trust (
trust_remote_code=True) only after code/server review, and document optional extras. - Use bundled references for details:
- API reference for
Tool,@tool, schemas, validation, serialization, and helper APIs. - Workflows for common recipes: decorator, subclass, structured output, MCP, Hub, Space, LangChain, and toolbox updates.
- Built-in tools for default tool capabilities and dependencies.
- Troubleshooting for common failures and fixes.
- API reference for
Minimal Examples
Decorator tools must have type hints, a return type, and an Args: docstring section for every argument:
from smolagents import tool
@tool
def normalize_label(label: str, lowercase: bool = True) -> str:
"""Normalize a user-facing label.
Args:
label: Label text to normalize.
lowercase: Whether to lowercase before replacing spaces.
"""
cleaned = label.strip().replace(" ", "_")
return cleaned.lower() if lowercase else cleaned
Subclass tools must define name, description, inputs, output_type, and forward:
from smolagents import Tool
class ReceiptLookupTool(Tool):
name = "receipt_lookup"
description = "Looks up a receipt summary by integer receipt id."
inputs = {"receipt_id": {"type": "integer", "description": "Receipt id to retrieve."}}
output_type = "string"
def forward(self, receipt_id: int) -> str:
return f"Receipt {receipt_id}: not connected to a database in this example."
Guardrails
- Do not put secrets, local checkout paths, or private environment paths into tool code, descriptions, or serialized Hub artifacts.
- Put imports used by a serializable tool inside methods/functions, not only at module scope, so
save(),to_dict(), andpush_to_hub()can reconstruct self-contained code. - Mark nullable/defaultable inputs consistently between
forwardtype hints andinputs; mismatches raise validation errors. - Treat
output_schemaas prompt/schema guidance for structured outputs; it does not replace testing the actual return value. - Install optional extras only for the integration being used, such as MCP, web search, webpage parsing, LangChain, Gradio, or Transformers pipeline tools.
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).