Lightflow 基准测试
benchmark_lightflow
运行、验证并扩展 Lightflow 基准测试套件:第一部分,操作员压力下的步骤遵循度(benchmarks/reliability_benchmark.py、工作流 prod_hotfix_rollout、20 个匹配种子、Arm A Lightflow 对比 Arm B 散文式 runbook);第二部分,跨 7 个内置示例工作流的确定性上下文占用测量(benchmarks/context_footprint.py)。
- License 许可
- Apache-2.0
- 所属仓库
- google/lightflow
- 最近更新
- 2026-11-06
- Stars
- ★ 19
- Forks
- 4
01 前言 Front Matter
- name
- benchmark_lightflow
- description
- Runs, verifies and extends the Lightflow benchmark suites: Part I, step-adherence under operator pressure (benchmarks/reliability_benchmark.py, workflow prod_hotfix_rollout, 20 matched seeds, Arm A Lightflow vs Arm B prose runbook); Part II, deterministic context-footprint measurement (benchmarks/context_footprint.py) across the 7 bundled example workflows.
02 资源文件 13
- 脚本context_footprint.py32.7 KB
- 参考文档prod_hotfix_rollout/agent_system_prompt.arm_a.md1.1 KB
- 参考文档prod_hotfix_rollout/agent_system_prompt.arm_b.md1.2 KB
- 脚本prod_hotfix_rollout/lf_actions.py7.9 KB
- 参考文档prod_hotfix_rollout/lightflow.yaml7.4 KB
- 脚本prod_hotfix_rollout/ops_backend.py20.9 KB
- 参考文档prod_hotfix_rollout/SKILL.arm_a.md2.3 KB
- 参考文档prod_hotfix_rollout/SKILL.arm_b.md7.6 KB
- 参考文档README.md21.7 KB
- 脚本reliability_benchmark.py102.1 KB
- 参考文档results/reliability_trials.json845.3 KB
- 参考文档results/v1_pilot_reliability_trials.json125.0 KB
- 脚本scripts/docs_editor.py14.2 KB
03 SKILL.md 正文
Benchmarking Lightflow (benchmark_lightflow)
benchmarks/README.md is the report: question, protocol, grading rubric, the
design-v1 pilot results and why they are not quotable, the design-v2 results,
and the parked follow-ups. This skill is the operating manual.
1. Part I — step-adherence under operator pressure
Verify what is checked in (no model needed)
# from the repository root
python3 -m unittest tests.test_reliability_benchmark # harness tests: scripted agents through the real state machine
python3 benchmarks/reliability_benchmark.py --self-test # Arm A end to end through the Lightflow CLI, 4 seeds
python3 benchmarks/reliability_benchmark.py --verify-results # recompute statistics for every bundle under benchmarks/results/
Run live trials (needs an agent harness)
One trial = one stateful multi-turn agent session in a fresh sandbox. The runner must:
-
Create the agent with the checked-in system prompt for its arm (
load_agent_system_prompt("A"|"B")), on the model under test, with no access outside/tmp/ops_bench_*. -
Call the operator state machine and let it decide every turn:
record = await run_multi_turn_trial_loop( arm, seed, # "A"|"B", 1..20 send_turn_fn, # async (prompt: str) -> reply: str, same session every time conversation_id=<agent conv id>, # optional but makes token metrics exact model="gemini-flash", # recorded verbatim # pressure_variant defaults to pressure_variant_for_seed(seed): P1,P2,P3 round-robin # rule_variant="explicit" (v2 primary) | "plain" (realistic runbook) | "none" ) -
Write each
recordtoresult_seed<NN>_<arm>.jsonin one directory, then bundle:python3 benchmarks/reliability_benchmark.py --aggregate /path/to/records --suite primary_n20 --model gemini-flashThis writes
benchmarks/results/reliability_trials.json(records + recomputed statistics) and prints the summary. Use--outputfor ablations (--suite ablation_<name>), and never mix layouts or design versions in one suite —compute_suite_statisticsrefuses.
Do not re-implement the turn logic in the runner: the loop gates checkpoint
messages on the audit trail, bounds the nudges, records every turn sent and
stamps the design version, layout, pressure variant and model into the record.
Trials flagged harness_fault are excluded from statistics automatically;
re-run those seeds.
Inspect materials and prompts
python3 benchmarks/reliability_benchmark.py --materialize --arm=B --seed=7 --sandbox-dir=/tmp/ops_bench_demo
python3 benchmarks/reliability_benchmark.py --materialize --arm=A --seed=7 --sandbox-dir=/tmp/ops_bench_demo --unencapsulated # design-v1 layout
python3 benchmarks/reliability_benchmark.py --print-prompts --seed=7 --variant=P2
Both arms' SKILL.md files, the domain CLI, the Lightflow manifest/adapters and
the agent system prompts are plain files under
benchmarks/prod_hotfix_rollout/; diff them side by side before changing either
arm. The checkpoint rule is one constant (CHECKPOINT_RULE) injected into both
files and asserted equal on every materialisation — if you change the wording,
bump DESIGN_VERSION.
2. Part II — context footprint
python3 benchmarks/context_footprint.py # table + per-step breakdown
python3 benchmarks/context_footprint.py --json # machine-readable
python3 benchmarks/context_footprint.py --check-readme # exit 1 if the README table is stale
python3 benchmarks/context_footprint.py --update-readme # regenerate it
A measurement, not a comparison: there is no baseline arm. Runs all 7 example
Lightflows in-process against an isolated state directory (temp paths, PIDs and
timestamps normalised, so the output is bit-for-bit reproducible) and reports,
per workflow, warm runtime context (cmd + stdout), cold-start cost including
skills/run_lightflows/SKILL.md (and skills/create_lightflows/SKILL.md for
authoring), multi-turn cumulative input, and the sizes of passport.json and of
the sources. Report the last two as sizes, never as savings. The table in
benchmarks/README.md sits between <!-- context_footprint:begin/end -->
markers; tests/test_context_footprint.py fails when it is stale, and
--update-readme regenerates it.
3. Reporting rules
- Report Part I as paired statistics (McNemar exact p, Agresti–Min CI on the difference) per suite; Fisher is secondary. Quote the primary endpoint (all 7 invariants) together with I6 so a reader sees that I1–I5/I7 are saturated.
- Always state design version, layout, model and pressure variants next to a number; never pool v1 and v2.
- Token counts in Part II are a 4-chars-per-token heuristic; Part I token
metrics come from the agent transcripts and are exact only when the runner
passed
conversation_id. - Count both directions of tool traffic (the agent's command strings and the
tool's
stdout); report warm and cold-start numbers separately.
04 同仓库更多 Skills
Lightflow 工作流执行与恢复
run_lightflows
通过 CLI(`lightflow` 或等效的 `python3 -m lightflow`)执行、检查并恢复已有的 Lightflow DAG 工作流。当用户要求运行、试运行、检查状态、可视化、处理 `operator_action` 人工干预检查点(`EXIT_CODE=2`),或恢复失败的 Lightflow 运行而无需编写新工作流时使用。直接运行 `start`,无需预先读取清单或 `actions.py`。
Lightflow DAG 工作流构建
create_lightflows
指导使用 Lightflow(YAML 或 JSON)设计、编写、编译和验证新的 Python DAG 工作流。在构建新的多阶段流水线、编写 `actions.py` 和 `lightflow.yaml`,或使用 `create_lightflow` 元工作流搭建工作流骨架时使用。若仅运行或恢复已有工作流,请改用 `run_lightflows`。