Skip to content

Bug: Chat halluccinates instead of using knowledge base for AutoBot documentation queries #1385

Closed

Description

@mrveiss

Problem

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

  1. 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
    • Added as Critical Rule Docs improvements #1: "NEVER hallucinate"
  2. Documentation indexing run on .20 to populate autobot_docs collection

Files Changed

  • autobot-backend/resources/prompts/chat/system_prompt_simple.md — anti-hallucination policy + web search fallback

Discovered During

User reported session 73ed69f7-97bc-46da-b1d1-dd321b2592de hallucinated install process info.

Impact

High — Users receive fabricated information presented as fact, eroding trust in the system.

Activity

  1. mrveiss commented on Mar 5, 2026

    @mrveiss
    OwnerAuthor

    Fix Applied

    1. System prompt updated

    Added anti-hallucination policy to resources/prompts/chat/system_prompt_simple.md:

    • 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
    • Rule Docs improvements #1: "NEVER hallucinate"

    2. Documentation indexed

    Ran index_documentation.py --full on .20:

    • 2913 documents indexed into autobot_docs ChromaDB collection
    • Query "how to install autobot" returns 3 results with scores 0.73-0.75
    • DocumentationSearcher confirmed working: recognizes doc queries and retrieves relevant chunks

    3. Backend restarted

    Restarted to pick up the new system prompt. Waiting for init to verify end-to-end.

    Root Cause Chain

    1. autobot_docs ChromaDB collection was empty (0 documents) → DocumentationSearcher.search() returned nothing
    2. _retrieve_documentation_context() returned empty → no doc context in LLM prompt
    3. autobot_memory KB also had no install docs → conversation_aware_retrieve() returned empty
    4. System prompt said "General questions → Answer helpfully" → LLM fabricated answer from training data
  2. mrveiss commented on Mar 5, 2026

    @mrveiss
    OwnerAuthor

    Resolved — Commit 19daec5

    Root Cause

    Two disconnected doc indexing systems existed:

    1. populate_autobot_docs API → stored whole files as Redis KB facts (autobot_memory)
    2. 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:

    1. 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)
    2. Refactored populate_autobot_docs endpoint — now delegates to DocIndexerService.index_all() instead of Redis KB store_fact()
    3. Auto-index on startup — background task in lifespan.py fires if autobot_docs collection is empty (non-blocking)
    4. Updated documentation watcher — uses DocIndexerService.index_file() for real-time reindexing on file changes
    5. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions