feat: add Evaluation + Optimization closed-loop example (#91) - #263
feat: add Evaluation + Optimization closed-loop example (#91)#263Ygrowly wants to merge 6 commits into
Conversation
- Fix Windows drive-colon parsing in _agent_evaluator eval set loader - Load optimizer credentials from gitignored .env; lazy-import live_agent - Remove internal notes and local tool config from the branch - Rewrite DESIGN.md as the 300-500 word design note required by trpc-group#91
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #263 +/- ##
==========================================
Coverage ? 87.87785%
==========================================
Files ? 482
Lines ? 45190
Branches ? 0
==========================================
Hits ? 39712
Misses ? 5478
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
AI Code Review发现的问题
|
…ro cmd - _run_evaluator: re-raise assertions that abort before results exist instead of masking them as empty NOT_EVALUATED outcomes - _build_repro_cmd: shlex.quote each argument so paths with spaces stay intact - Add tests covering both swallowed-assertion paths and repro cmd quoting
|
两点都已修复,见 d6085ff:
按建议补了 tests/test_evaluator_error_handling.py:覆盖'断言且无结果必须抛出'、'case 失败保留结构化结果'、复现命令 shlex.split round-trip 三个用例。示例测试 73 项全部通过。 |
|
I have read the CLA Document and I hereby sign the CLA |
AI Code Review所有导出内容均存在。很好。现在让我来撰写最终的审查意见。 发现的问题
|
- Add POSIX-only case loading an existing path that contains ':' so the drive-letter guard is covered on Linux CI as well - Pass absolute paths to evaluator/optimizer now that the SDK guards the case selector, removing process-wide chdir and metric-config copying
|
两点都已处理,见 d99414f:
|
AI Code Review
我已经审查完毕。该 PR 很稳健。让我写一下审查结论,指出几个值得注意的真正需要权衡的地方。 发现的问题
|
- Audit callback: normalize whitespace when matching queries and degrade to an unmatched-marked entry instead of raising KeyError mid-optimize - live_agent: extract response_text_from_event using getattr so parts without thought/text attributes cannot break regression runs - GateConfig: reject non-positive budget_tokens/budget_usd to keep G6 meaningful - Add tests for trimmed-query matching, unknown-query degradation, thought-less parts and budget validation
|
三条意见都已在 3221408 处理: query 匹配(pipeline.py):不再抛 KeyError。匹配前对 query 做空白归一化(strip + 折叠连续空白),仍未命中时降级为空上下文继续执行,并在审计条目里加 part.thought(live_agent.py):把文本拼接提取成 budget_tokens 边界(gates.py): 示例测试 78 passed,flake8 无告警。 |
AI Code Review基于我对 diff 和相关仓库上下文(CI 配置、pytest 配置、SDK 调用)的分析,以下是我的审查结果。 发现的问题
|
feat: Evaluation + Optimization 自动回归与提示词优化闭环示例 (#91)
Refs #91
概述
新增
examples/optimization/eval_optimize_loop/,实现 Issue #91 要求的"评测 → 失败归因 → prompt 优化 → 回归验证 → 产物审计" Champion–Challenger 闭环:
输入 train/val evalset + optimizer.json + prompt 源文件,输出
optimization_report.{json,md}与是否接受候选的 Gate 决策;默认 dry-run,仅 ACCEPT 且显式
--apply时经TargetPrompt原子写回。交付物(对照 Issue)
AgentEvaluator)、按 evaluator 证据的失败归因、AgentOptimizer.optimize(update_source=False)原生优化、候选 val 回归逐 case 对比、G1–G7 可配置 Gate、审计落盘(唯一 run_id、frozen.json 哈希清单、逐轮候选、成本、耗时、种子)
optimization_report.example.json示例输出;DESIGN.md 为 300–500 字方案设计说明验收对照
真实 API 端到端验证
已用 DeepSeek(OpenAI 兼容端点)跑通
--mode optimize:GEPA reflective 4 轮、42 条模型调用全部审计落盘、Gate 正确 REJECT(无有效提升 + 成本证据缺失禁止自动写回)。
凭据经示例目录下被 gitignore 的
.env读取,不进仓库。SDK 修复说明(examples 之外的唯一改动)
trpc_agent_sdk/evaluation/_agent_evaluator.py:"file.json:case_id"冒号切分与 Windows 盘符路径(如
C:\...\Temp\batch.evalset.json,GEPA adapter 的临时文件)冲突,导致
Eval set file not found: C。最小修复:仅当完整路径不存在且冒号左侧为存在文件时才按 case 选择器解析。
tests/evaluation全套回归通过。测试