You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Chat halluccinates instead of using knowledge base for AutoBot documentation queries #1385
When users ask AutoBot chat about its own install process (or other AutoBot-specific topics), the LLM fabricates answers instead of retrieving from the knowledge base.
Root Cause
Two compounding issues:
1. autobot_docs ChromaDB collection is empty (0 documents)
The DocumentationSearcher at services/knowledge/doc_searcher.py:669 returns empty because no documentation has been indexed into the autobot_docs collection. The indexing script (autobot-infrastructure/shared/tools/index_documentation.py) was never run on the production backend.
2. System prompt lacks anti-hallucination guardrail
The chat system prompt (resources/prompts/chat/system_prompt_simple.md) line 13 says "General questions → Answer helpfully" with no instruction to ground answers in sources. When RAG returns nothing, the LLM generates from training data — which has zero knowledge of AutoBot internals.
Fix Applied
System prompt updated with "No Hallucination Policy" section:
Every factual claim must come from KB context, command output, or web search
When no KB context is available, explicitly say so and search the web
populate_autobot_docs API → stored whole files as Redis KB facts (autobot_memory)
index_documentation.py CLI tool → stored chunked docs in ChromaDB (autobot_docs)
The ChromaDB collection was never populated because the CLI tool was never wired into any lifecycle or API. When the chat RAG pipeline queried autobot_docs, it found 0 documents and the LLM hallucinated answers.
Fix
Consolidated into a single system with ChromaDB as the single source of truth:
New DocIndexerService (services/knowledge/doc_indexer.py) — extracted from CLI tool, adapted for service use (SSOT config, centralized ChromaDB client, incremental SHA-256 hash cache)
Refactored populate_autobot_docs endpoint — now delegates to DocIndexerService.index_all() instead of Redis KB store_fact()
Auto-index on startup — background task in lifespan.py fires if autobot_docs collection is empty (non-blocking)
Updated documentation watcher — uses DocIndexerService.index_file() for real-time reindexing on file changes
Anti-hallucination guardrail — added "No Hallucination Policy" to system prompt requiring KB/command/web grounding
Verification
Backend healthy on .20, doc_searcher initialized with 2913 documents
Search for "how do I install autobot" returns relevant results (scores 0.74-0.75)
POST /api/knowledge_base/populate_autobot_docs returns success with correct counts
Background indexing completes without blocking startup
Activity
mrveiss commentedon Mar 5, 2026
Fix Applied
1. System prompt updated
Added anti-hallucination policy to
resources/prompts/chat/system_prompt_simple.md:2. Documentation indexed
Ran
index_documentation.py --fullon .20:autobot_docsChromaDB collectionDocumentationSearcherconfirmed working: recognizes doc queries and retrieves relevant chunks3. Backend restarted
Restarted to pick up the new system prompt. Waiting for init to verify end-to-end.
Root Cause Chain
autobot_docsChromaDB collection was empty (0 documents) →DocumentationSearcher.search()returned nothing_retrieve_documentation_context()returned empty → no doc context in LLM promptautobot_memoryKB also had no install docs →conversation_aware_retrieve()returned emptyfeat(knowledge): consolidate doc indexing with ChromaDB as single sou…
mrveiss commentedon Mar 5, 2026
Resolved — Commit 19daec5
Root Cause
Two disconnected doc indexing systems existed:
populate_autobot_docsAPI → stored whole files as Redis KB facts (autobot_memory)index_documentation.pyCLI tool → stored chunked docs in ChromaDB (autobot_docs)The ChromaDB collection was never populated because the CLI tool was never wired into any lifecycle or API. When the chat RAG pipeline queried
autobot_docs, it found 0 documents and the LLM hallucinated answers.Fix
Consolidated into a single system with ChromaDB as the single source of truth:
DocIndexerService(services/knowledge/doc_indexer.py) — extracted from CLI tool, adapted for service use (SSOT config, centralized ChromaDB client, incremental SHA-256 hash cache)populate_autobot_docsendpoint — now delegates toDocIndexerService.index_all()instead of Redis KBstore_fact()lifespan.pyfires ifautobot_docscollection is empty (non-blocking)DocIndexerService.index_file()for real-time reindexing on file changesVerification
POST /api/knowledge_base/populate_autobot_docsreturns success with correct counts