Skip to content

Handle None latency gracefully in PerformanceCostMetric - #286

Merged
priyanshu250808 merged 1 commit into
mainfrom
claude/bug-investigation-fixes-rbq6lk
Aug 16, 2026
Merged

Handle None latency gracefully in PerformanceCostMetric#286
priyanshu250808 merged 1 commit into
mainfrom
claude/bug-investigation-fixes-rbq6lk

Conversation

@himanshu231204

Copy link
Copy Markdown
Member

Description

This PR improves the robustness of the PerformanceCostMetric.evaluate() method to gracefully handle cases where latency measurement is unavailable (e.g., when no LLM is configured or generation fails).

Previously, the method defaulted missing latency_ms to 0.0, which could mask scenarios where latency data was genuinely unavailable. Now it explicitly checks for None values and returns a score of 0.0 with appropriate metadata indicating that no measurement was available.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Test update

How Has This Been Tested?

Added two new unit tests:

  • test_none_latency_does_not_raise: Verifies that explicitly passing latency_ms=None is handled gracefully
  • test_missing_latency_kwarg_does_not_raise: Verifies that omitting latency_ms entirely behaves the same as passing None

Both tests confirm that the metric returns a score of 0.0 and includes appropriate metadata.

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes

Additional Notes

This change improves observability by distinguishing between "no latency measurement available" (returns 0.0 with latency_ms: None in metadata) and actual latency values, making it easier to debug scenarios where latency data is missing.

https://claude.ai/code/session_01WBiH9ViQkKjAr6knTz4AWA

kwargs.get("latency_ms", 0.0) only falls back to the default when the
key is missing, not when it's explicitly None. The pipeline always
passes latency_ms as a kwarg (None when no LLM is configured or
generation fails), so `None < 0` crashed on every such evaluation -
reproduced in every report checked into reports/*.json.

Fixes #285
Copilot AI lite review requested due to automatic review settings August 16, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@priyanshu250808
priyanshu250808 merged commit 5013614 into main Aug 16, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Congratulations @himanshu231204!

Your pull request has been successfully merged into main. 🚀

Thank you for contributing to OpenAgentHQ and helping improve the project.

We truly appreciate your contribution and hope to see you back with more amazing PRs!

Happy Open Sourcing! ❤️

@himanshu231204 himanshu231204 mentioned this pull request Aug 17, 2026
4 tasks
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.

4 participants