examples-auto-run

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

examples-auto-run

示例自动运行工具

What it does

功能说明

  • Runs
    pnpm build && pnpm -r build-check
    first
  • Runs
    pnpm examples:start-all
    in auto-input mode (interactive prompts are auto-answered, HITL/MCP/apply-patch are auto-approved).
  • Executes starts in parallel (default concurrency 4) and pipes each start’s stdout/stderr into its own log file under
    .tmp/examples-start-logs/
    .
  • Provides start/stop/status/logs/tail helpers via
    run.sh
    .
  • If the Codex session ends (no disown/nohup), the child processes receive SIGHUP and exit;
    stop
    is also available to clean up manually.
  • 首先执行
    pnpm build && pnpm -r build-check
  • 以自动输入模式运行
    pnpm examples:start-all
    (交互式提示将自动应答,HITL/MCP/apply-patch将自动批准)
  • 并行启动实例(默认并发数为4),并将每个启动进程的stdout/stderr输出到
    .tmp/examples-start-logs/
    目录下的独立日志文件中
  • 通过
    run.sh
    提供启动/停止/状态查看/日志查看/日志追踪等辅助功能
  • 如果Codex会话结束(未使用disown/nohup),子进程将收到SIGHUP信号并退出;也可使用
    stop
    命令手动清理

Usage

使用方法

bash
undefined
bash
undefined

Start (auto mode, concurrency=4 by default)

启动(自动模式,默认并发数为4)

.agents/skills/examples-auto-run/scripts/run.sh start [extra args to examples:start-all]
.agents/skills/examples-auto-run/scripts/run.sh start [传递给examples:start-all的额外参数]

If you invoke the skill name alone ($examples-auto-run):

如果直接调用技能名称(
$examples-auto-run
):

- when
.tmp/examples-rerun.txt
exists and is non-empty, it will run
rerun
automatically

- 当
.tmp/examples-rerun.txt
文件存在且非空时,将自动执行
rerun
命令

- otherwise it runs the default
start
command.

- 否则将执行默认的
start
命令

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
.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
.agents/skills/examples-auto-run/scripts/run.sh status

Stop running job (kills pid from .tmp/examples-auto-run.pid)

停止运行中的任务(终止
.tmp/examples-auto-run.pid
中记录的进程)

.agents/skills/examples-auto-run/scripts/run.sh stop
.agents/skills/examples-auto-run/scripts/run.sh stop

List logs (per start script)

列出所有日志(按启动脚本分类)

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

Tail latest log

追踪最新日志

.agents/skills/examples-auto-run/scripts/run.sh tail .agents/skills/examples-auto-run/scripts/run.sh tail basic__start_hello-world.log
.agents/skills/examples-auto-run/scripts/run.sh tail .agents/skills/examples-auto-run/scripts/run.sh tail basic__start_hello-world.log

After a run, build a rerun list from the latest main log (auto-skip list is imported from
scripts/run-example-starts.mjs
and server/audio/external skips are honored)

运行完成后,从最新的主日志中生成重跑列表(自动跳过列表将从
scripts/run-example-starts.mjs
导入,同时会遵循server/audio/external的跳过规则)

.agents/skills/examples-auto-run/scripts/run.sh collect
.agents/skills/examples-auto-run/scripts/run.sh collect

Rerun only the entries in .tmp/examples-rerun.txt

仅重跑
.tmp/examples-rerun.txt
中记录的条目

.agents/skills/examples-auto-run/scripts/run.sh rerun
.agents/skills/examples-auto-run/scripts/run.sh rerun

Show the current auto-skip list (env or defaults)

显示当前的自动跳过列表(来自环境变量或默认值)

.agents/skills/examples-auto-run/scripts/run.sh start --print-auto-skip --dry-run
undefined
.agents/skills/examples-auto-run/scripts/run.sh start --print-auto-skip --dry-run
undefined

Defaults (overridable via env)

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

  • EXAMPLES_INTERACTIVE_MODE=auto
  • AUTO_APPROVE_MCP=1
    ,
    APPLY_PATCH_AUTO_APPROVE=1
    ,
    AUTO_APPROVE_HITL=1
    (set in runner)
  • EXAMPLES_CONCURRENCY=4
  • EXAMPLES_EXECA_TIMEOUT_MS=300000
    (5m)
    financial-research-agent
    and
    computer-use
    use 10m inside the script.
  • Includes interactive; excludes server/audio/external by default:
    • EXAMPLES_INCLUDE_INTERACTIVE=1
    • EXAMPLES_INCLUDE_SERVER=0
    • EXAMPLES_INCLUDE_AUDIO=0
  • EXAMPLES_INCLUDE_EXTERNAL=0
    • This means
      realtime-*
      /
      nextjs
      (tagged as server/audio) are skipped unless you opt in with
      --include-server
      /
      --include-audio
      or the corresponding env flags.
  • Auto-skip list:
    EXAMPLES_AUTO_SKIP
    (comma/space separated) overrides the built-in defaults used by both
    run.sh
    and
    run-example-starts.mjs
    . Defaults include
    agent-patterns:start:llm-as-a-judge
    ,
    agent-patterns:start:routing
    ,
    customer-service:start
    ,
    connectors:start
    ,
    mcp:start:hosted-mcp-on-approval
    ,
    mcp:start:hosted-mcp-human-in-the-loop
    .
  • EXAMPLES_INTERACTIVE_MODE=auto
  • AUTO_APPROVE_MCP=1
    ,
    APPLY_PATCH_AUTO_APPROVE=1
    ,
    AUTO_APPROVE_HITL=1
    (由运行器设置)
  • EXAMPLES_CONCURRENCY=4
  • EXAMPLES_EXECA_TIMEOUT_MS=300000
    (5分钟)
    financial-research-agent
    computer-use
    在脚本内设置为10分钟
  • 默认包含交互式示例;排除server/audio/external类型的示例:
    • EXAMPLES_INCLUDE_INTERACTIVE=1
    • EXAMPLES_INCLUDE_SERVER=0
    • EXAMPLES_INCLUDE_AUDIO=0
  • EXAMPLES_INCLUDE_EXTERNAL=0
    • 这意味着
      realtime-*
      /
      nextjs
      (标记为server/audio)将被跳过,除非通过
      --include-server
      /
      --include-audio
      或对应的环境变量手动开启
  • 自动跳过列表:
    EXAMPLES_AUTO_SKIP
    (逗号/空格分隔)将覆盖
    run.sh
    run-example-starts.mjs
    使用的内置默认值。默认包含
    agent-patterns:start:llm-as-a-judge
    ,
    agent-patterns:start:routing
    ,
    customer-service:start
    ,
    connectors:start
    ,
    mcp:start:hosted-mcp-on-approval
    ,
    mcp:start:hosted-mcp-human-in-the-loop

Cancellation / cleanup

取消/清理

  • Jobs are backgrounded but not disowned; if Codex suspends/ends the shell, the process group gets SIGHUP and stops.
  • Manual cleanup:
    run.sh stop
    (removes stale pid if already exited).
  • 任务将在后台运行但未脱离会话;如果Codex暂停/结束shell,进程组将收到SIGHUP信号并停止
  • 手动清理:
    run.sh stop
    (如果进程已退出,将移除无效的pid文件)

Log locations

日志位置

  • .tmp/examples-start-logs/<package>__<script>.log
    (per start)
  • Main runner log path is printed when
    start
    is invoked.
  • Rerun list (generated by
    collect
    ):
    .tmp/examples-rerun.txt
    (one
    package:script
    per line).
  • .tmp/examples-start-logs/<package>__<script>.log
    (每个启动脚本对应独立日志)
  • 主运行器日志路径将在执行
    start
    命令时打印
  • 重跑列表(由
    collect
    生成):
    .tmp/examples-rerun.txt
    (每行一个
    package:script
    条目)

Notes

注意事项

  • Auto-skip is centralized (same defaults as above) and can be overridden via
    EXAMPLES_AUTO_SKIP
    . Auto-skip entries are excluded from rerun collection and will be removed from rerun execution automatically.
  • Auto-input map covers common interactive prompts; HITL/MCP/apply-patch auto-approve via env is enabled by the runner.
  • Shell tool approvals are auto-approved in auto mode (
    SHELL_AUTO_APPROVE=1
    ).
  • rerun
    runs entries sequentially, continues after failures, and rewrites
    .tmp/examples-rerun.txt
    with only the remaining failures. Auto-skip entries are not re-added.
  • Behavioral validation is not done in the runner, so Codex must immediately perform it after every
    start
    or
    rerun
    invocation without waiting for the user to ask.
    Required steps:
    1. Read the example source to infer intended flow from code/comments (tools invoked, expected outputs, guards, approvals).
    2. Read the matching log under
      .tmp/examples-start-logs/
      .
    3. Compare intent vs. log: confirm key actions/results happened; flag omissions or divergences.
    4. Do this for all exit-0 entries, not just samples.
    5. Summarize findings right after the run completes; when “OK”, note what was checked (e.g., “tools called + final message emitted”).
    6. When reporting, do not omit or ellipsize outputs that justify the validation; include the full relevant lines (keep it concise but untruncated).
  • The runner prints a full table after the summary: one row per start script with
    status
    ,
    package:script
    ,
    info
    (reason/exit/skipped), and the log path. If the run stops before the table appears, point the analyzer at the latest
    main_*.log
    to reconstruct a table and validations.
  • 自动跳过列表是集中管理的(默认值如上),可通过
    EXAMPLES_AUTO_SKIP
    覆盖。自动跳过的条目将被排除在重跑列表收集之外,且在重跑时会自动被忽略
  • 自动输入映射覆盖常见的交互式提示;运行器会通过环境变量开启HITL/MCP/apply-patch的自动批准
  • 在自动模式下,Shell工具的批准将自动通过(
    SHELL_AUTO_APPROVE=1
  • rerun
    命令将按顺序执行条目,失败后会继续执行,并将
    .tmp/examples-rerun.txt
    重写为仅包含未成功的条目。自动跳过的条目不会被重新添加
  • 运行器不会执行行为验证,因此Codex必须在每次
    start
    rerun
    调用完成后立即执行验证,无需等待用户请求
    。验证步骤如下:
    1. 读取示例源码,从代码/注释中推断预期流程(调用的工具、预期输出、防护机制、批准操作)
    2. 读取
      .tmp/examples-start-logs/
      目录下对应的日志文件
    3. 对比预期与实际日志:确认关键操作/结果已执行;标记遗漏或偏离的情况
    4. 所有退出码为0的条目执行此验证,而非仅抽样
    5. 运行完成后立即总结验证结果;如果“验证通过”,需注明检查的内容(例如:“已确认工具调用+最终消息输出”)
    6. 报告时请勿省略或截断用于验证的输出内容;需包含完整的相关行(保持简洁但不截断)
  • 运行器在总结后会打印完整的表格:每行对应一个启动脚本,包含
    状态
    package:script
    信息
    (原因/退出码/已跳过)以及日志路径。如果运行在表格打印前停止,需引导分析人员查看最新的
    main_*.log
    以重建表格并完成验证