feat(evaluation): offline evaluation module with uv run evaluate CLI#280
Open
ShuxinLin wants to merge 9 commits into
Open
feat(evaluation): offline evaluation module with uv run evaluate CLI#280ShuxinLin wants to merge 9 commits into
ShuxinLin wants to merge 9 commits into
Conversation
Implement src/evaluation/ — consumes saved agent trajectories
({run_id}.json under AGENT_TRAJECTORY_DIR) and scenario files, joins
them on scenario_id, runs a registered grader per scenario, and emits
a JSON report combining grading results with operational metrics
(tokens, duration p50/p95, tool calls, optional cost estimate).
The shape follows SWE-bench / HELM / τ-bench conventions: agent run
→ evaluate → report.json, with offline re-grading from saved
trajectories as a first-class workflow.
Includes:
- Pydantic models (Scenario, PersistedTrajectory, GradeResult,
OpsMetrics, EvalReport)
- Loader for trajectory dirs and JSON/JSONL scenario files
- Grader registry with two deterministic graders
(exact_string_match, numeric_match) and a pluggable LLM judge
bound to LLMBackend (six-criterion rubric)
- Per-task ops metric extraction (handles both SDK Trajectory and
plan-execute list[StepResult] shapes) plus aggregate rollups
- Report writer with terminal summary and JSON output
- evaluate script registered in [project.scripts]
- 39 unit tests covering models, loader, graders, metrics, report,
and end-to-end runner — all passing alongside existing 270 tests
Closes #279
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Collaborator
|
https://mlflow.org/docs/latest/genai/concepts/scorers/ Please use these concept and prefer to use Scorer
|
This was referenced Apr 29, 2026
# Conflicts: # pyproject.toml Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Reviewer feedback (PR #280): align with MLflow's evaluator/scorer split. - Rename src/evaluation/graders/ -> src/evaluation/scorers/ and organise by family: code_based (exact/numeric), llm_judge (LLM-As-Judge), semantic (new). - Rename GradeResult -> ScorerResult with field `scorer` (Scenario input field `grading_method` unchanged — input contract preserved). - Add `Evaluator` class as the orchestration entry point; functional `evaluate()` now delegates to it. - Add Semantic-Score scorer using difflib.SequenceMatcher (stdlib only, no extra deps); threshold overridable via scenario.similarity_threshold. - CLI: add --scorer-default (keeps --grader-default as alias). Tests: 7 new (4 semantic + 2 evaluator + 1 registry); 46 total in src/evaluation/, full suite 316 passed. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Code-Based scorers (exact_string_match, numeric_match) are now skeleton stubs raising NotImplementedError; the family slot in the Evaluator/Scorer taxonomy is preserved but implementations are deferred. Registry no longer auto-registers them on import. Tests for behavior removed; new TestCodeBasedSkeletons asserts NotImplementedError. test_runner and test_evaluator override tests re-pointed at semantic_similarity. 41 evaluation tests pass. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
…warg
- LLM-As-Judge prompt now mirrors src/tmp/evaluation_agent/result_evaluation_prompt.py:
full 6-criterion rubric text, split Agent's Thinking vs Final Response,
output schema uses `suggestions` (back-compat: `reason` still accepted),
parser strips "(END OF RESPONSE)" sentinel.
- CLI: LiteLLMBackend takes `model_id=`, not `model=`. Fixes:
TypeError: LiteLLMBackend.__init__() got an unexpected keyword argument 'model'
Verified end-to-end: claude-agent on groundtruth/101 ("List all failure
modes of asset Chiller.") → uv run evaluate with --scorer-default
llm_judge → 6/6 criteria pass.
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
- CLI: --output FILE replaced with --reports-dir DIR (default reports/). Writes one JSON per result (named by trajectory run_id, which is a UUID) plus _aggregate.json for the rollup. - ScenarioResult now carries run_id (propagated from PersistedTrajectory). - New report.write_reports_dir(); falls back to scenario-<id>.json for legacy trajectories with no run_id. - 2 new tests; 43 evaluation tests pass. Verified: uv run evaluate against groundtruth/101.json wrote reports/112c1b56-...json + reports/_aggregate.json. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
- Strip src/evaluation/scorers/semantic.py to a NotImplementedError skeleton; no longer auto-registered. Code-Based + Semantic-Score families now both ship as slot-only placeholders; LLM-As-Judge is the only working scorer in this branch. - Tests: TestSemanticSimilarity collapsed to a NotImplementedError assertion; runner/evaluator override tests pivot to local stub scorers (no skeleton dependency). - INSTRUCTIONS.md: new Evaluation section linking to the full doc. - docs/evaluation.md: scenario/trajectory schema, CLI reference, report layout, scorer families table, custom-scorer plug-in pattern, loop over groundtruth/*.json. 40 evaluation tests pass; full suite 310 passed. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
13 tasks
DhavalRepo18
approved these changes
May 13, 2026
Collaborator
DhavalRepo18
left a comment
There was a problem hiding this comment.
We want to use Evaluator and Scorer (universal terminology).
Field and identifier renames so the module speaks a single vocabulary: - Scenario.grading_method -> Scenario.scoring_method - ScenarioResult.grade -> ScenarioResult.score (typed ScorerResult) - runner.default_grading_method -> runner.default_scoring_method - CLI: --grader-default legacy alias removed (only --scorer-default) - report.totals["graded"] -> report.totals["scored"] - Docstrings/comments/docs: "grading"/"graded"/"grader" -> "scoring"/"scored"/"scorer" Tests, INSTRUCTIONS.md, docs/evaluation.md updated. Note: the inner numeric ScorerResult.score is unchanged; access is result.score.score for the numeric, result.score.passed for the bool. 40 evaluation tests pass; full suite 310 passed; end-to-end against groundtruth/101.json still emits 6/6 rubric pass. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
…dd aggregate JSON shape Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
src/evaluation/— an offline scorer for saved agent trajectories. Follows MLflow's evaluator/scorer split per reviewer feedback: anEvaluatordispatches to one of three scorer families.llm_judgesrc/tmp/evaluation_agent/result_evaluation_prompt.pyexact_string_match,numeric_matchNotImplementedError), not auto-registeredsemantic_similarityInterface
Writes
reports/<run_id>.jsonper trajectory andreports/_aggregate.jsonfor the rollup.Scenario field
scoring_methodselects the scorer per-scenario;--scorer-defaultis the fallback.Docs
docs/evaluation.md— schema, CLI, output layout, custom-scorer pattern, groundtruth loop. Pointer fromINSTRUCTIONS.md.Test plan
uv run pytest src/evaluation/— 40 passeduv run pytest src/ -k "not integration"— 310 passedgroundtruth/101.jsonwithllm_judge— 6/6 rubric pass, reports writtenCloses #279