Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(answer): stop echoing the question in the recovery hint (#3009)
Raghav Chamadiyab93aef29babc
diff --git a/packages/server/src/repowise/server/mcp_server/tool_answer/answer.py b/packages/server/src/repowise/server/mcp_server/tool_answer/answer.pyindex 04f3a9cb8..c965e5578 100644--- a/packages/server/src/repowise/server/mcp_server/tool_answer/answer.py+++ b/packages/server/src/repowise/server/mcp_server/tool_answer/answer.py@@ -349,7 +349,7 @@ async def get_answer(Responses fit 24,000 serialized chars. Pass ``include=["evidence"]`` forthe deduplicated expanded evidence projection (32,000 chars). Reductions- carry counts and an exact recovery call.+ carry counts and a recovery: repeat the call with that include.Args:question: developer question.@@ -730,7 +730,7 @@ async def get_answer(Responses fit 24,000 serialized characters. Pass ``include=["evidence"]``for the deduplicated expanded projection, capped at 32,000. Reductions carry- totals, emitted counts, reasons, and an exact one-call recovery.+ totals, emitted counts, reasons, and a recovery: the same call with that include.Args:question: Developer question.diff --git a/packages/server/src/repowise/server/mcp_server/tool_answer/projection.py b/packages/server/src/repowise/server/mcp_server/tool_answer/projection.pyindex f5ee68c2d..38a17f756 100644--- a/packages/server/src/repowise/server/mcp_server/tool_answer/projection.py+++ b/packages/server/src/repowise/server/mcp_server/tool_answer/projection.py@@ -328,8 +328,8 @@ def _default_shape(payload: dict[str, Any], question: str) -> None:def _record_reductions(- payload: dict[str, Any], totals: dict[str, int], *, question: str, scope: str | None,- repo: str | None, expanded: bool+ payload: dict[str, Any], totals: dict[str, int], *, scope: str | None, repo: str | None,+ expanded: bool) -> None:reduced = Falsefor key in _COLLECTIONS:@@ -344,12 +344,19 @@ def _record_reductions(reduced = Trueif reduced and not expanded:projection = payload.setdefault("_meta", {}).setdefault("projection", {})- arguments: dict[str, Any] = {"question": question, "include": ["evidence"]}+ # The caller already holds the question; restating a long one costs+ # tokens on every reduced reply. Short scope and repo stay, so a caller+ # that rebuilds the call from this block cannot widen it silently.+ arguments: dict[str, Any] = {"include": ["evidence"]}if scope is not None:arguments["scope"] = scopeif repo is not None:arguments["repo"] = repo- projection["recovery"] = {"tool": "get_answer", "arguments": arguments}+ projection["recovery"] = {+ "tool": "get_answer",+ "same_arguments": True,+ "arguments": arguments,+ }def project_answer_payload(@@ -370,9 +377,7 @@ def project_answer_payload(for key in _COLLECTIONS:if not payload.get(key):payload.pop(key, None)- _record_reductions(- payload, totals, question=question, scope=scope, repo=repo, expanded=expanded- )+ _record_reductions(payload, totals, scope=scope, repo=repo, expanded=expanded)unknown = sorted(set(include or []) - {"evidence"})if unknown:payload.setdefault("_meta", {})["ignored_arguments"] = {"include": unknown}diff --git a/tests/fixtures/mcp/tool_response_shapes.json b/tests/fixtures/mcp/tool_response_shapes.jsonindex 2675de91d..2ee27c01a 100644--- a/tests/fixtures/mcp/tool_response_shapes.json+++ b/tests/fixtures/mcp/tool_response_shapes.json@@ -11,9 +11,9 @@"arguments": {"include": [null- ],- "question": null+ ]},+ "same_arguments": null,"tool": null}},diff --git a/tests/unit/server/mcp/test_answer_projection.py b/tests/unit/server/mcp/test_answer_projection.pyindex 28c421a90..9040e8596 100644--- a/tests/unit/server/mcp/test_answer_projection.py+++ b/tests/unit/server/mcp/test_answer_projection.py@@ -192,12 +192,10 @@ def test_adversarial_duplicate_evidence_survives_once_with_exact_recovery():assert compact["retrieval_reduced_reason"] == "confidence_projection_and_deduplication"assert compact["_meta"]["projection"]["recovery"] == {"tool": "get_answer",- "arguments": {- "question": "how does auth work",- "include": ["evidence"],- "scope": "src/auth",- },+ "same_arguments": True,+ "arguments": {"include": ["evidence"], "scope": "src/auth"},}+ assert "how does auth work" not in json.dumps(compact["_meta"])assert expanded["retrieval"], "the advertised one-call expansion must recover evidence"