Skip to content

feat(kb): ingest has no partial-success state — a timeout discards every page already read #17986

Open

Description

@mrveiss

Part of #17527. Blocked by #17830.

Problem

Knowledge-base ingest has no partial-success state. add_document (autobot-backend/knowledge/documents.py) performs a single wait_for and stores nothing when it expires, so a long PDF that runs out of time loses every page already read. The work was done; the result is discarded.

The two outcomes a caller can observe are "fully stored" and "nothing stored". There is no third, and the one that actually happens for large documents — "most of it was read and then the clock ran out" — reports as the second.

Why this is the expensive shape

It is not merely lossy, it is silently lossy in a way that makes retry worse:

  • A retry starts from zero, so a document that cannot finish inside one budget can never finish, no matter how many times it is retried. Each attempt pays full cost for nothing.
  • Nothing records how far it got, so there is no signal distinguishing "this document is too big for the budget" from "the extractor crashed". Both are an empty collection.
  • The failure scales with document value: the longer and richer the source, the more certain it is to be lost.

Proposal

  • A per-document time budget, explicit rather than implicit in a single wait_for.
  • A PARTIAL status recorded per chunk, so what was read is kept and what was not is known.
  • Resumption from the last stored chunk rather than from the beginning.

Sequencing

Blocked by #17830: add_document does not chunk at all today — a whole transcript or PDF becomes one unit. Per-chunk partial status has nothing to attach to until chunking exists, so this must land after it. Recording the dependency rather than duplicating #17830's work.

Acceptance criteria

Related

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions