tools-handoffs-guardrails
Build function tools, local and hosted tool surfaces, agents-as-tools, handoffs, approvals, and guardrails in openai-agents-python.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- tools-handoffs-guardrails
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Build function tools, local and hosted tool surfaces, agents-as-tools, handoffs, approvals, and guardrails in openai-agents-python.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md14.1 KB
- 参考文档references/troubleshooting.md10.4 KB
- 参考文档references/workflows.md15.3 KB
- 脚本scripts/validate_function_tool_schema.py7.7 KB
03 SKILL.md 正文
Tools, Handoffs, and Guardrails
Use this sub-skill when a task mentions @function_tool, function schemas, hosted or local tools, ShellTool, ComputerTool, ApplyPatchTool, agents-as-tools, handoffs, human approval, input/output guardrails, or tool guardrails.
Start Here
- Read references/api-reference.md for current constructor/decorator options, selection tables, and API boundaries.
- Read references/workflows.md for copyable patterns: basic function tools, approval flow, agents-as-tools versus handoffs, deferred tool search, shell/apply-patch/computer tools, and guardrails.
- Read references/troubleshooting.md when schema generation, strict mode, approvals, guardrail timing, tool lookup, hosted/local execution, or
ComputerToolmodel migration is surprising. - Run scripts/validate_function_tool_schema.py to inspect safe local
@function_toolschema behavior without model or API calls.
Routing Boundaries
- Use this sub-skill for Python function tools, SDK built-in tool classes,
Agent.as_tool(),handoff(...),ToolExecutionConfig, HITL approval pauses, and agent/tool guardrails. - Route MCP server lifecycle, local MCP configuration, and hosted MCP depth to ../mcp-and-hosted-tools/SKILL.md; keep only high-level hosted tool selection here.
- Route model/provider setup, Responses versus Chat Completions compatibility, and
OpenAIProviderchoices to ../models-providers/SKILL.md. - Route sandbox agents, manifests, Docker/hosted sandbox clients, and sandbox capability wiring to ../sandbox-agents/SKILL.md.
- Route runner lifecycle, sessions, server-managed conversations, streaming, and
RunStatepersistence details to ../core-runtime/SKILL.md.
Working Rules
- Prefer
@function_toolfor ordinary Python functions; use explicitFunctionToolonly when you need a custom raw JSON invoker or manually built schema. - Keep
strict_mode=Trueunless you have verified the target model/provider accepts the looser schema and you have a fallback for validation errors. - Use
Agent.as_tool()when a manager should keep conversation control; usehandoff(...)when a specialist should become the active agent. - Use tool guardrails for checks around every custom function-tool call; agent input guardrails only cover the first agent input, and agent output guardrails only cover the final-producing agent.
- Treat approval-gated tools as resumable interruptions: inspect
result.interruptions, convert toRunState, approve/reject, then resume the original top-level run.
Evidence Base
This sub-skill distills the repository docs, source, examples, and tests for tools, handoffs, HITL approvals, guardrails, ToolExecutionConfig, deferred tool search, and local/hosted runtime tools. It intentionally bundles patterns instead of linking to original examples so future agents do not depend on a source checkout.
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).