feat(mcp): ground get_answer synthesis in the body it serves; slim low-confidence misses#778
Merged
Merged
Conversation
…w-confidence misses
Synthesis fed the LLM a 40-line source excerpt for a question-matched
symbol while the response inlined the symbol's full 120-line body. A
docstring-heavy definition was therefore truncated before its
answer-bearing logic ever reached the model, so synthesis hedged
("not in the excerpts") on the very symbol whose full body the response
then handed to the agent. Read the top matched symbols at the
inline-body depth during hydration so the model reasons over the same
body the response serves, and add a calibration test that locks the two
depths together.
Also slim the low-confidence miss payload. The gated response carried a
full per-hit key_symbols dump that duplicated best_guesses and went
unused; drop it (best_guesses + code_rationale carry the choosing
signal) along with the excerpt-enrichment DB round-trip that only fed
it. The low-confidence answer branch keeps a grounding block but lean,
with symbols pipeable and docstrings stripped.
Extracts the symbol_bodies ranking into a tested _gather_body_candidates
helper. Battery green; unit tests added.
|
✅ Health: 7.6 (unchanged) 📋 At a glance Files & modules (2)
🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)
🔎 More signals (3)🔥 Hotspots touched (4)
1 more
🔗 Hidden coupling (3 files)
💀 Dead code (1 finding)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-11 11:19 UTC |
swati510
approved these changes
Jul 11, 2026
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.
What
Two get_answer quality fixes surfaced by dogfooding the MCP tools.
1. Synthesis now sees the same body it serves
For a question-matched symbol, the hydrator fed the synthesis LLM a 40-line source excerpt while the response inlined the symbol's full 120-line body in
symbol_bodies. A docstring-heavy definition (its logic past line 40) was truncated before its answer-bearing code reached the model, so synthesis hedged with a low-confidence "not in the excerpts" answer on the very symbol whose full body the agent then received.The top matched symbols are now read at the inline-body depth during hydration, so the model reasons over the same body the response serves. Bounded so a class-name flood (every sibling method matching through the parent's qualified name) cannot balloon the synthesis prompt.
2. Cheaper low-confidence misses
A low-confidence miss carried a full per-hit
key_symbolsdump that duplicatedbest_guessesand went unused. It is dropped (best_guesses+code_rationalecarry the choosing signal), along with the page-excerpt DB round-trip that only fed it. The low-confidence answer branch keeps a grounding block but lean: hits with snippets, symbols pipeable, docstrings stripped.Also extracts the
symbol_bodiesranking into a tested_gather_body_candidateshelper.Testing