Skip to content

fix: prevent TypeError in metrics collect_metrics when reward is None#243

Open
JasonOA888 wants to merge 1 commit intobenchflow-ai:mainfrom
JasonOA888:fix/metrics-reward-comparison-typeerror
Open

fix: prevent TypeError in metrics collect_metrics when reward is None#243
JasonOA888 wants to merge 1 commit intobenchflow-ai:mainfrom
JasonOA888:fix/metrics-reward-comparison-typeerror

Conversation

@JasonOA888
Copy link
Copy Markdown

@JasonOA888 JasonOA888 commented May 7, 2026

collect_metrics picks the best result per task across retries by comparing reward values. When a verifier returns rewards={"reward": None, "rubric": [...]} (a truthy dict with a None reward), the comparison float > None raises TypeError.

This can happen when a rubric verifier returns partial results — individual items pass but the overall reward is unresolved.

Fix: add _safe_reward() helper that normalizes None/missing reward values to 0.0 before comparison.

Repro:

# First attempt: rewards with None reward (rubric verifier partial result)
# Second attempt: rewards with 0.5 reward
# Comparison: 0.5 > None → TypeError!
<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/benchflow-ai/benchflow/pull/243" target="_blank">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
    <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open in Devin Review">
  </picture>
</a>
<!-- devin-review-badge-end -->

collect_metrics picks the best result per task across retries by comparing
reward values. When a verifier returns rewards={'reward': None, 'rubric': [...]}
(a dict with a None reward), the comparison  raises TypeError.

Fix: add _safe_reward() helper that normalizes None/missing reward values
to 0.0 before comparison.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

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.

1 participant