Skip to content

fix(evaluations): normalize dictionary results in batch runs - #2021

Open
ningyixi wants to merge 1 commit into
langfuse:mainfrom
ningyixi:fix/batch-dictionary-evaluations
Open

ningyixi wants to merge 1 commit into
langfuse:mainfrom
ningyixi:fix/batch-dictionary-evaluations

Conversation

@ningyixi

@ningyixi ningyixi commented Oct 18, 2026 •

Copy link
Copy Markdown

What does this PR do?

Batch evaluation accepts dictionary evaluator results but passes them straight to _create_score(), which expects Evaluation attributes. Returning {"name": "quality", "value": 0.75} therefore fails the item with 'dict' object has no attribute 'metadata'. A composite evaluator returning a dictionary logs the same error and produces no composite score.

Normalize item and composite results with the existing _normalize_evaluator_result() used by experiments. This converts dictionaries, lists of dictionaries, and mixed dictionary/Evaluation lists into Evaluation objects before score creation, while preserving score metadata, comments, type, and config ID.

Ten regression cases cover sync/async item evaluators and composites through the batch runner, with local observation fixtures and assertions on the score calls. All ten fail before the runtime change.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Documentation update
  • Tooling, CI, or repo maintenance

Verification

uv sync --locked --python 3.13
uv run --frozen pytest tests/unit/test_batch_evaluation.py tests/unit/test_experiment.py -q
uv run --frozen ruff check .
uv run --frozen ruff format --check .
uv run --frozen mypy langfuse --no-error-summary
uv run --frozen pre-commit run --all-files

The focused suite has 59 passing tests. Ruff, formatting (575 files), mypy, and all pre-commit hooks pass.

The full unit suite also passes: 932 passed, 2 skipped on Python 3.13.5, using four workers. The existing prompt fixture needs LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY; a first run without them had 18 fixture setup errors (914 passed). Rerunning with dummy local test credentials and LANGFUSE_BASE_URL=http://localhost:3000 passed the whole suite. No real credentials were used.

No Langfuse server or live provider tests were run. Provider instrumentation and generated API files are unchanged.

Checklist

  • I self-reviewed the diff using code_review.md.
  • I added tests for behavior changes.
  • Existing evaluator/composite documentation already describes dictionary results; no examples or environment contracts change.
  • I did not hand-edit generated files.
  • I did not commit secrets or credentials.

Developed and checked with Codex assistance.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

Batch evaluations now use the existing _normalize_evaluator_result() helper before creating item and composite scores.

  • Batch runs turn dictionary evaluator results into scores.

Reviews (1) · Last reviewed commit: "fix(evaluations): normalize dictionary r..." · Reviewed by Greptile

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@CLAassistant

CLAassistant commented Oct 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants