Skip to content

Oversized .qmd/.html/.yaml/.skill documents are silently truncated at 20k chars before the semantic pass — only 5 of 10 document types are sliceable #2900

Closed

Description

@abhay-codes07

Summary

_read_files caps every unit at _FILE_CHAR_CAP (20,000 characters) before joining it into the user message. expand_oversized_files exists precisely so an oversized document is split into contiguous FileSlices that together cover the whole file — but it only splits suffixes listed in _SPLITTABLE_TEXT_SUFFIXES, and that list has drifted from detect.DOC_EXTENSIONS.

reach the semantic pass : .html .md .mdx .pdf .qmd .rst .skill .txt .yaml .yml
sliced when oversized   : .markdown .md .mdx .rst .txt
never sliced            : .html .pdf .qmd .skill .yaml .yml

Anything in that third row loses everything past 20,000 characters, silently.

Reproduce

A 38,411-character document, same content, five different extensions:

  .md      splittable=True   units=3   chars reaching the LLM=38411  LOST=0
  .qmd     splittable=False  units=1   chars reaching the LLM=20000  LOST=18411
  .html    splittable=False  units=1   chars reaching the LLM=20000  LOST=18411
  .yaml    splittable=False  units=1   chars reaching the LLM=20000  LOST=18411
  .skill   splittable=False  units=1   chars reaching the LLM=20000  LOST=18411

Why it is worse than it looks

  • Nothing reports it. There is no warning, no _partial_files marker (that machinery tracks truncated responses, not truncated inputs), and nothing in GRAPH_REPORT.md. The graph looks complete.
  • Nothing in the tail can ever become a node. The semantic pass never sees the text, so the loss is invisible from inside the graph too — you cannot tell a document with a sparse second half from one that was cut.
  • It is silent per-file, so it scales quietly. A corpus of long .html docs loses roughly the same fraction of every one of them.
  • graphify's own .skill files are in the gap, and they are well over 20k characters.

.md has worked correctly since #1369; the other document types were added to DOC_EXTENSIONS later and the splittable list was never updated to match.

Suggested fix

Add the plain-text document types — .qmd, .skill, .html, .yaml, .yml — to _SPLITTABLE_TEXT_SUFFIXES. _file_to_text reads all of them with a straight read_text, so a character range over the raw file is exactly what the model is shown; they slice identically to .md.

More importantly, pin the relationship so it cannot drift again: assert that every non-binary DOC_EXTENSION is splittable, so adding a document type without deciding how it gets sliced fails loudly instead of quietly dropping tails.

.pdf is the harder half

I would leave .pdf out of a first fix. Its bytes are not what the model sees — _file_to_text routes it through extract_pdf_text, while read_slice_text does path.read_text() — so slicing needs the converter threaded through the slicing path first. Worth its own change, but note that a paper over 20,000 characters is truncated today, and papers are among the longest things anyone points graphify at.

There is also a small mirror inconsistency: .markdown is in _SPLITTABLE_TEXT_SUFFIXES but not in DOC_EXTENSIONS, so it is never classified as a document in the first place.

I have the non-PDF half working with tests and will open a PR shortly.

Environment

graphify v8 @ b14b52e (0.9.47)
Python 3.12, Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions