mcpField
E
examples-auto-run

examples-auto-run

github.com/openai测试与质量30.4k139 次安装1 天前更新
代码仓库

关于 examples-auto-run

examples-auto-run 是通过 Shell 脚本运行和管理仓库示例套件的技能,支持自动交互、逐例日志、失败重跑和后台执行;行为验证仍需手动完成。

主要功能

  1. 01启动、停止和检查运行
  2. 02启用可选依赖扩展
  3. 03记录逐例及主日志
  4. 04生成失败示例列表
  5. 05按保存列表重跑失败项
  6. 06支持后台执行

适用场景

  1. 01自动输入运行示例
  2. 02检查运行状态和日志
  3. 03重跑运行失败的示例
  4. 04测试后收集运行结果

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/openai/openai-agents-python --skill examples-auto-run

安装后在 Claude Code 中输入/examples-auto-run确认已加载。

附带文件agents/openai.yamlscripts/run.sh

详细介绍

examples-auto-run

功能说明

  • 运行 uv run examples/run_examples.py,并带上以下设置:
    • 默认启用的可选依赖 extras: litellm、any-llm、sqlalchemy、redis、blaxel、modal、runloop 和 temporal。
    • EXAMPLES_INTERACTIVE_MODE=auto(自动输入/自动批准)。
    • 每个示例的日志位于 .tmp/examples-start-logs/ 下。
    • 通过 --main-log 传入的主汇总日志路径(同样位于 .tmp/examples-start-logs/ 下)。
    • 设置 --write-rerun 时,会在 .tmp/examples-rerun.txt 生成失败项的重跑列表。
  • 通过 run.sh 提供 start/stop/status/logs/tail/collect/rerun 辅助命令。
  • 后台选项会借助 pidfile 让进程保持运行;stop 会负责清理它。

用法

# Start (auto mode; interactive included by default)
.agents/skills/examples-auto-run/scripts/run.sh start [extra args to run_examples.py]
# Examples:
.agents/skills/examples-auto-run/scripts/run.sh start --filter basic
.agents/skills/examples-auto-run/scripts/run.sh start --include-server --include-audio

# Check status
.agents/skills/examples-auto-run/scripts/run.sh status

# Stop running job
.agents/skills/examples-auto-run/scripts/run.sh stop

# List logs
.agents/skills/examples-auto-run/scripts/run.sh logs

# Tail latest log (or specify one)
.agents/skills/examples-auto-run/scripts/run.sh tail
.agents/skills/examples-auto-run/scripts/run.sh tail main_20260113-123000.log

# Collect rerun list from a main log (defaults to latest main_*.log)
.agents/skills/examples-auto-run/scripts/run.sh collect

# Rerun only failed entries from rerun file (auto mode)
.agents/skills/examples-auto-run/scripts/run.sh rerun

Codex 执行环境

  • 当 Codex 调用 start 或 rerun 时,默认在 Codex 沙箱之外运行该命令(sandbox_permissions=require_escalated)。许多示例会启动嵌套沙箱、浏览器、npm 辅助进程,或云端/本地服务进程;如果在 Codex 沙箱内运行,可能会出现仅因环境导致的失败,例如 sandbox-exec: sandbox_apply: Operation not permitted、Playwright 缓存权限错误或 npm 缓存权限错误。
  • 仅当用户明确要求,或运行不会执行示例的小范围 dry-run / 日志检查命令时,才使用沙箱内执行。

默认值(可通过环境变量覆盖)

  • EXAMPLES_INTERACTIVE_MODE=auto
  • EXAMPLES_INCLUDE_INTERACTIVE=1
  • EXAMPLES_INCLUDE_SERVER=0
  • EXAMPLES_INCLUDE_AUDIO=0
  • EXAMPLES_INCLUDE_EXTERNAL=0
  • EXAMPLES_UV_EXTRAS="litellm any-llm sqlalchemy redis blaxel modal runloop temporal"(设为空字符串可禁用 extras)
  • auto 模式下的自动批准:APPLY_PATCH_AUTO_APPROVE=1、SHELL_AUTO_APPROVE=1、AUTO_APPROVE_MCP=1

日志位置

  • 主日志:.tmp/examples-start-logs/main_*.log
  • 单个示例日志(由 run_examples.py 生成):.tmp/examples-start-logs/<module_path>.log
  • 重跑列表:.tmp/examples-rerun.txt
  • 标准输出日志:.tmp/examples-start-logs/stdout_*.log

注意事项

  • 该运行器会委托给 uv run --extra ... examples/run_examples.py,后者本身已会写入单个示例日志,并支持 --collect、--rerun-file 和 --print-auto-skip。
  • 由于凭据问题,examples/sandbox/extensions/vercel_runner.py 目前被临时排除在自动运行之外。在凭据配置修复之前,请勿强制运行它。
  • start 使用 --write-rerun,因此失败项会被自动记录。
  • 如果 .tmp/examples-rerun.txt 存在且非空,在不带参数调用该 skill 时,默认会执行 rerun。

行为验证(Codex/LLM 职责)

运行器不会执行任何自动化的行为验证。每次前台执行 start 或 rerun 之后,Codex 必须人工验证所有退出码为 0 的条目:

  1. 阅读示例源码(及其注释),推断预期流程、使用的工具以及预期的关键输出。
  2. 打开 .tmp/examples-start-logs/ 下对应的单个示例日志。
  3. 确认预期的操作/结果已经发生;标记遗漏或偏差。
  4. 对所有已通过的示例逐一执行,而不是只抽查部分。
  5. 运行结束后立即汇报,并附上能够支撑验证结论的确切日志行引用,且引用保持简洁。

评论

支持 Markdown