feat: add Evaluation + Optimization closed-loop pipeline (#91)#194
feat: add Evaluation + Optimization closed-loop pipeline (#91)#194DNKYr wants to merge 16 commits into
Conversation
… remove unused import - Remove unused GateDecision import from test_reporting.py - Add test_write_reports_per_case_delta_all_transitions covering all 4 transition types in per-case delta table: newly_passing, newly_failing, passed (both), failed (both) - Coverage: reporting.py 100% (119/119 lines)
…rator - Fix Optional[callable] -> Optional[Callable] with typing.Callable import - Add tests for _write_eval_config_temp, _run_optimization injection hook, and run() trace mode - Remove unused imports (Path, EvalConfig, EvalSetAggregateResult, GateDecision from pipeline.py) - Remove unused imports (AgentEvaluator, EvalConfig, PipelineResult, GateConfig from tests)
- Add 3 integration tests: ACCEPT, REJECT, and overfitting scenario - Fix pipeline._run_eval to catch _EvaluationCasesFailed (expected when eval cases fail; result is populated before the exception is raised, matching the pattern used by run_evaluator in the SDK) - All 43 tests pass (40 existing + 3 new)
…mple output, gitignore
AI Code Review我已经获取了所有行号。现在让我来撰写审查意见。 发现的问题
|
- run_pipeline.py: REJECT exits 0 by default; added --fail-on-reject for CI - pipeline.py: live mode validates evalset/optimizer config file existence - pipeline.py: note cost_usd=0 is intentional (not yet collected from optimizer) - pipeline.py: add asyncio.wait_for timeout enforcement for live mode - test_pipeline.py: fix mock to return different baseline/candidate data - test_models.py: remove dead code (unused path variable, discarded dump)
AI Code Review发现的问题🚨 Critical
|
- Add missing import asyncio (live-mode path would NameError) - Guard _EvaluationCasesFailed private import with ImportError fallback - Remove /tmp whitelist hack in _resolve_paths (use isabs() only) - Warn via stderr when max_cost_usd is set but cost tracking unimplemented - Fix test isolation: use tempfile instead of shared /tmp paths - Add example tests to CI (testpaths + workflow command)
Critical fixes: - _build_split_result: skip empty case_results (all([])=True phantom pass) - overfitting detection: require val_pass_rate_delta < 0 (not <= 0) - total_cases: count only evaluable cases, not dict key count - _EvaluationCasesFailed fallback: warn on ImportError before using AssertionError Important fixes: - gate.py: protected_case_ids check both train and val score deltas - reporting.py: metric breakdown title shows correct split label - run_pipeline.py: use public output_dir property instead of private _config - pipeline.py: expose output_dir property, _collect_cost method Other: - failure_attribution.py: document format patterns as heuristic defaults
|
Second review round addressed in c681780. Additionally ran an adversarial self-review which caught 4 more critical issues: Fixes from your review:
Extra fixes from adversarial self-review:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #194 +/- ##
==========================================
Coverage ? 87.88291%
==========================================
Files ? 467
Lines ? 44103
Branches ? 0
==========================================
Hits ? 38759
Misses ? 5344
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Implements the Evaluation + Optimization automated regression and prompt optimization closed loop as described in #91.
What was built
A new
examples/optimization/eval_optimize_loop/package with:Pipeline (
EvalOptimizePipeline)AgentEvaluatoron train and val evalsetsAgentOptimizer; trace mode uses pre-cooked promptsoptimization_report.json(machine-readable) +optimization_report.md(human-readable)Sample data
Test coverage
Closes #91