Frontmatter
| title | docs: Promote ask_knowledge_base as primary Anti-Hallucination tool (#9893) |
| author | tobiu |
| state | Merged |
| createdAt | Apr 11, 2026, 9:56 PM |
| updatedAt | Apr 11, 2026, 10:04 PM |
| closedAt | Apr 11, 2026, 10:04 PM |
| mergedAt | Apr 11, 2026, 10:04 PM |
| branches | dev ← agent/9893-promote-ask-knowledge-base |
| url | https://github.com/neomjs/neo/pull/9894 |

Input from Claude Opus 4.6 (Antigravity):
❋ Iterative Update (force-push):
Fixed
CodebaseOverview.md"When Stuck" step 2 per user review. The previous wording suggested usingquery_documentsas a follow-up to locate files, butask_knowledge_basealready returns ranked file references with full paths and scores in its response. The redundantquery_documentscall was replaced withgrep_search/view_fileas the natural next step for drilling into specific implementations.-1. **Ask first:** ... — gets a synthesized answer with citations -2. **Then locate files:** `query_documents(query='afterSet hook', type='src')` — if you need the actual source code +1. **Ask first:** ... — gets a synthesized answer with cited source file paths +2. **Drill into code:** The answer includes ranked file references — use `grep_search` or `view_file` to inspect the specific implementation

Input from Claude Opus 4.6 (Antigravity):
❋ # PR Review Summary
Status: Approved
Clean documentation-only PR. Four files surgically edited to promote
ask_knowledge_basefrom an undocumented tool to the #1 position in the anti-hallucination hierarchy. The PR body is a proper Fat Ticket with rationale, scope deviation documentation, and cross-references. Iterative force-push was correctly documented via comment.
📊 Evaluation Metrics
[ARCH_ALIGNMENT]: 95 - Correctly positionsask_knowledge_baseas a zero-cost RAG subagent within the existing Anti-Hallucination framework. The tool hierarchy table in AGENTS.md §2.1 follows the established cascading-priority pattern used across other protocol sections. Minor deduction: the openapi.yaml decision table uses ❌/✅ which may not render in all YAML consumers.[CONTENT_COMPLETENESS]: 90 - All four documentation surfaces are covered (AGENTS.md, AGENTS_STARTUP.md, openapi.yaml, CodebaseOverview.md). Cross-references between files are bidirectional. The iterative PR comment documents the force-push delta. Deduction: noAGENTS.md§6 (Request Triage) update — that section says "using the knowledge base and other tools" generically and could also benefit from theask_knowledge_basecallout.[EXECUTION_QUALITY]: 95 - YAML parse validated via node. No formatting regressions. The "When Stuck" fix (removing redundantquery_documentsstep) was caught by user review and correctly addressed. All edits are additive — no existing semantics were broken.[PRODUCTIVITY]: 100 - All goals of #9893 achieved plus the #9892 comment scope extension. The user's review feedback was incorporated in-session.[IMPACT]: 75 - This is a force-multiplier for all future agent sessions. Every agent that reads AGENTS.md (i.e., every agent) will now default toask_knowledge_baseinstead of the wastefulquery_documents → read 5 fileschain. However, the actual behavioral change depends on whether LLM providers weight OpenAPI descriptions and protocol docs equally in tool selection.[COMPLEXITY]: 20 - Documentation-only. Four files, 74 insertions, 12 deletions. No code logic, no tests, no architectural risk.[EFFORT_PROFILE]: Quick Win - High ROI (affects every agent session) with minimal complexity and zero regression risk.
🕸️ Context & Graph Linking
- Target Epic / Issue ID: Resolves #9893
- Related Graph Nodes: #9892 (CodebaseOverview expansion — partially addressed via the Query Entry Points / When Stuck changes), #9891 (Strategic Constraint Nodes — downstream consumer of better tool selection),
ask_knowledge_baseoperationId,query_documentsoperationId
🧠 Graph Ingestion Notes
[KB_GAP]: Theask_knowledge_basetool existed since the KB MCP server's inception but had zero references in agent operational protocols (AGENTS.md). This gap caused systematic under-utilization — agents defaulted toquery_documentsbecause it had 70+ lines of OpenAPI documentation vs 12 forask_knowledge_base. Root cause: tool documentation asymmetry directly drives tool selection in LLMs.[TOOLING_GAP]:get_pull_request_diffMCP tool failed with exit code 1 for PR #9894 during this review. Fell back togh pr diffvia shell. Worth investigating — may be a timing issue with recently force-pushed PRs.[RETROSPECTIVE]: This PR validates a meta-architectural insight: documentation IS architecture for AI-native systems. The behavioral change isn't in code — it's in how future agents will select tools based on the weight of documentation surrounding each tool. The "zero-cost RAG subagent" framing is a conceptual anchor that should be reinforced in future onboarding materials.
📋 Required Actions
None — approved for merge.
Optional enhancement for a follow-up commit: Consider adding an
ask_knowledge_basecallout to AGENTS.md §6 (Request Triage), which currently says "using the knowledge base and other tools" generically. This would close the last documentation surface that references KB tools without specifying the priority order.
Summary
Resolves #9893 Partially addresses #9892 (CodebaseOverview scope extension per comment)
Changes
AGENTS.md — §2 Anti-Hallucination Policy (Major)
ask_knowledge_baseas the #1 toolquery_documents → read 5 fileswaste patternopenapi.yaml — ask_knowledge_base description (Major)
query_documentsdocumentation qualityAGENTS_STARTUP.md — §3.4 Ask the Expert Protocol (Minor)
CodebaseOverview.md — Query Entry Points + When Stuck (Minor, from #9892 comment)
ask_knowledge_baseRationale
ask_knowledge_baseis architecturally the most powerful anti-hallucination primitive — a zero-cost RAG subagent that even local SLMs can invoke. Despite this, it had zero mentions in AGENTS.md, a 12-line OpenAPI description (vs 70+ forquery_documents), and no mention in CodebaseOverview. Agents systematically defaulted to the multi-file-read pattern, wasting context window.Scope Deviation
Added CodebaseOverview.md changes (from #9892 comment scope extension) that were not in the original #9893 body. These are logically inseparable — promoting the tool in agent protocols without updating the primary onboarding document would leave a gap.