fix(metrics): stop silently swallowing DeepEval exceptions in the hallucination metric#220
Merged
himanshu231204 merged 3 commits intoJul 23, 2026
Conversation
…swallowing The hallucination metric caught `except Exception: pass`, hiding runtime failures (missing API key, network error, model init failure) behind a silent switch to the word-coverage fallback — users had no indication the sophisticated DeepEval path had failed. Match the sibling Faithfulness / AnswerRelevancy pattern: catch `(ImportError, Exception)` and emit a `logger.debug` trace before falling back. Add regression tests asserting the failure is logged and that evaluate() still degrades gracefully rather than propagating. Fixes OpenAgentHQ#72 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
🎉 Congratulations @Nitjsefnie! 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! ❤️ |
Merged
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.
Fixes #72
Replaces the bare
except: passblocks with the exact pattern the sibling Faithfulness/AnswerRelevancy metrics use —logurulogger.debug(...)on the caught exception, then the word-coverage fallback. One deliberate divergence from the issue text: the issue suggestedlogger.warning, but the siblings uselogger.debug, and consistency across the generation metrics seemed the stronger contract — happy to bump the level across all three in a follow-up if you'd rather warn.Tests assert the failure is logged and that
evaluate()still degrades to the fallback (loguru isn't captured by pytest'scaplognatively, so the test bridges a loguru sink to the caplog handler).Gates:
uv run pytest tests/unit— 936 passed, 4 skipped (+2 new).Generated by Claude Fable 5 (brief, review), Claude Opus 4.8 (implementation)