fix(diagnosis): require low relevancy before blaming short answers as off-topic - #263
Merged
himanshu231204 merged 3 commits intoJul 31, 2026
Conversation
Cover both directions: legitimate short answers ("Yes.", "42",
"Paris") with good generation scores must not be blamed, and a short
answer corroborated by low answer relevancy must still be flagged.
Adapt test_empty_answer_blames_generation to supply the corroborating
signal the maintainer's option 2 requires.
Co-Authored-By: Kimi K3 <noreply@kimi.com>
…entHQ#66) A short answer alone is not a generation failure: legitimate answers like "Yes.", "42" or "Paris" were blamed on generation with 0.7 confidence, skewing blame summaries. Keep the length heuristic as one signal and only attribute OFF_TOPIC_ANSWER when corroborated by low answer_relevancy, a metric already computed in _analyze_generation. Co-Authored-By: Kimi K3 <noreply@kimi.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! ❤️ |
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.
Description
_analyze_generationflagged any answer shorter thanANSWER_TOO_SHORT = 10characters asOFF_TOPIC_ANSWER, so legitimate short answers — "Yes.", "42", "Paris" — were blamed on the generation component with 0.7 confidence, skewing the blame summary andoverall_health.The length heuristic is now one signal rather than the whole test: a short answer is only flagged when
answer_relevancyalso indicates a problem.Type of Change
Related Issues
Closes #66
How Has This Been Tested?
uv run pytest tests/unit -v --tb=short→ 1010 passed, 5 skipped)Coveragejob (--cov-fail-under=75→ 1064 passed, 80.67%)uv run ruff check .) — see note belowuv run mypy openagent_eval/) — see note belowTests cover both directions, because a narrowed heuristic and a disabled one are otherwise indistinguishable:
I picked your second suggestion rather than lowering the threshold, because a smaller constant only moves the boundary — "42" is still two characters, and any threshold admitting it also admits genuinely truncated output.
Checklist
Additional Notes
Two things I checked because they looked like they could be regressions, and want to report either way.
First, empty answers. Requiring corroboration could in principle swallow the clearest true positive there is, so I ran it: an empty answer with a hypothetically healthy relevancy score would indeed go unflagged — but that state is unreachable, because
AnswerRelevancy.evaluatereturns a hard0.0with "No answer provided" for an empty answer (relevancy.py:54), and_run_metricsalways records it. End to end, an empty answer is still blamed on generation withoverall_health0.0. I therefore did not add a length-0 special case, since it would guard a state the metric layer already makes impossible.Second,
test_empty_answer_blames_generationneeded a fixture adjustment. Worth saying plainly what changed: its assertion is untouched, and despite the name it never contained an empty answer — its fixture was an instance of the very false-positive class this issue describes. It now supplies the corroborating signal explicitly.One disclosed consequence of this approach: if a user configures a metric set without
answer_relevancy, the corroborating signal is absent and the short-answer heuristic goes inert rather than firing. That is inherent to gating on another metric, not something a carve-out should hide — flagging it in case you would rather it fall back to length-only when relevancy is unavailable.On the two unchecked test boxes.
ruff check .exits 1 on pre-existing findings atmainitself, so I could not honestly tick it. Per-file atmainversus this branch: one pre-existingI001in the test file, zero new findings.mypyis unticked for the same reason — not clean atmain, and unchanged by this diff.Generated by Claude Opus 5 (brief, review), Kimi K3 (implementation)