Skip to content

fix(metrics): stop silently swallowing DeepEval exceptions in the hallucination metric#220

Merged
himanshu231204 merged 3 commits into
OpenAgentHQ:mainfrom
Nitjsefnie-OSC:fix/hallucination-exception-logging
Jul 23, 2026
Merged

fix(metrics): stop silently swallowing DeepEval exceptions in the hallucination metric#220
himanshu231204 merged 3 commits into
OpenAgentHQ:mainfrom
Nitjsefnie-OSC:fix/hallucination-exception-logging

Conversation

@Nitjsefnie

Copy link
Copy Markdown
Contributor

Fixes #72

Replaces the bare except: pass blocks with the exact pattern the sibling Faithfulness/AnswerRelevancy metrics use — loguru logger.debug(...) on the caught exception, then the word-coverage fallback. One deliberate divergence from the issue text: the issue suggested logger.warning, but the siblings use logger.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's caplog natively, 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)

Nitjsefnie and others added 3 commits July 23, 2026 18:02
…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>
@himanshu231204
himanshu231204 merged commit a1e8027 into OpenAgentHQ:main Jul 23, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 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! ❤️

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.

metrics(hallucination): silently swallows all DeepEval exceptions hiding runtime errors

2 participants