Skip to content

bug(kb): the stats endpoint reports one collection as total_documents — 359 of 18,341 vectors, 2% of the store #17626

Open

Description

@mrveiss

The misreport

GET /api/knowledge_base/stats on the live deployment (commit 9027bf7e6):

{"total_documents": 359, "total_chunks": 359, "total_vectors": 359,
 "total_facts": 1, "categories": ["round-trip-17527"]}

ChromaDB on the same host, same moment:

autobot_code    11241
autobot_docs     6741
autobot_memory    359

359 is autobot_memory alone. The endpoint names its fields total_documents,
total_chunks and total_vectors and answers for one of at least three populated
collections. The store holds 18,341 vectors; the endpoint reports 2% of them.

categories: ["round-trip-17527"] is the same shape one level down: that is the only
category among the facts, and it was created minutes earlier by a test probe. An
operator reading it concludes the knowledge base contains one test category.

Why it matters more than a wrong number

It is the instrument an operator and an agent both reach for first. I read it, and
reported to my user that the knowledge base held no AutoBot documentation — while
6,741 documentation chunks sat in autobot_docs. The conclusion was wrong, it was
confidently stated, and the endpoint's field names are why: total_documents does not
say "documents in one of the collections".

That is the recurring defect family in this repository: a plausible number answering a
narrower question than its name implies, with nothing signalling the narrowing.

Acceptance criteria

  • The endpoint reports the whole store, or names what it is reporting on. A field
    called total_documents that covers one collection is the defect; the same
    number under memory_collection_documents is not.
  • Per-collection counts are available, so a collection that exists and is empty is
    distinguishable from one that is not reported.
  • categories states its scope — facts, or the whole store.
  • A test asserts the reported total against the sum of the collections it claims to
    cover, so the two cannot drift.

Related

#17625 (the retrieval path queries only the collection this endpoint reports, which is
why one defect hid the other). #12733 (facts and vectors disagreeing, from the other
direction).

Activity

  1. added
    needs-structureMissing goal milestone, matching phase label or native parent (#19522)
    on Nov 2, 2026
  2. github-actions commented on Nov 2, 2026

    @github-actions
    Contributor

    needs-structure: this issue is missing:

    • a goal milestone M<n> - ...: v0.9.6 - knowledge base is not a goal milestone
    • a phase:M<n>.<k> label whose <n> matches the goal milestone: found none

    The label clears on the next issue event once all three are present (#19522).

  3. mrveiss commented on Nov 21, 2026

    @mrveiss
    OwnerAuthor

    Related sighting, from read-only host evidence on a local install at main d8cbd91925 (2026-11-21). GET /api/knowledge_base/stats reports total_facts 511, while GET /api/knowledge_base/facts/by_category pages through 978 facts (total_count 978). This is a facts count, not a vector count, so it may be a second counter with the same kind of fault. It is recorded here rather than as a new issue until someone confirms whether it shares the root.

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

    backendbugSomething isn't workingneeds-structureMissing goal milestone, matching phase label or native parent (#19522)

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions