Skip to content

Semantic extraction silently truncates every file at 20,000 characters (_FILE_CHAR_CAP), no warning #3773

Closed

Description

@cabgab-dev

Summary

Semantic (LLM) extraction silently reads only the first 20,000 characters of every file (_FILE_CHAR_CAP = 20_000 in graphify/llm.py), with no warning and no error. For files well above that size — a long CLAUDE.md, a design doc, a project plan — this means most of the file's content is invisible to the graph, silently.

Environment

  • Installed: graphifyy 0.8.31 (pip show graphifyy)
  • Confirmed still present on main / latest release (0.9.66, 2026-09-22): _FILE_CHAR_CAP = 20_000 at graphify/llm.py:30, used unconditionally in _read_files (truncates before building the prompt) and in the token-estimate helpers around line 2090-2134.

Reproduction

  1. Create/point at any prose file (.md) larger than 20,000 characters — a CLAUDE.md accumulated over months of a real project is a common case.
  2. Run /graphify --update (or extract_corpus_parallel(...) directly) with GEMINI_API_KEY set.
  3. Compare len(open(file).read()) against the node count graphify produces for that file.

Actual behavior

  • The extraction call returns failed_chunks: 0 and a normal-looking result — nothing signals truncation.
  • Real case: a 229,319-character CLAUDE.md (project history/decisions) was read up to character 20,000 (8.7% of the file) and produced 11 nodes. Once manually split into <18k-char chunks at heading boundaries and re-extracted, the same file produced 215 nodes — the other 91.3% of the file had simply never reached the model.
  • Across one real corpus (~430 files), 29 documents exceeded the cap; some plans were seen as low as 8.7%–50% of their actual content, all without any indication in the CLI output.

Expected behavior

At minimum: print a warning (like the existing "extraction warning: N issues" pattern) whenever a file is truncated by _FILE_CHAR_CAP, naming the file and the percentage lost. Ideally: split an oversized file into multiple chunks (the same way the corpus itself is already chunked across files) and extract each chunk, merging nodes back onto the original source_file — this is what we ended up implementing as a workaround.

Workaround we're using

A small script that: audits which files exceed the cap, splits each one into <18k-char tramos (cutting on markdown ## headings, falling back to line breaks for an oversized single section), extracts each tramo with extract_corpus_parallel, and reassigns any node whose source_file the model pointed elsewhere back to the correct original document (by checking which candidate document's text mentions the node's label). Happy to share it if useful, but a native fix (at least the warning) would remove the need for every user to discover this independently.

Related

Not a duplicate of the shrink-guard issues (#3579, #3580, #2229, #2976) — this is upstream of those, in extraction input, not in the merge/write path. No existing issue found for _FILE_CHAR_CAP / truncation / "20000" in search.

Activity

  1. Souptik96 commented on Sep 26, 2026

    @Souptik96
    Contributor

    Before picking this up I checked it against current main (0.9.68). I think the case you hit is already fixed:

    As a quick check, expand_oversized_files on a synthetic 218,050-character CLAUDE.md returned 11 slices covering all 218,050 characters, none over 20,000.

    Your repro was on 0.8.31, which predates #1369. Could you re-run on the latest release? If the large CLAUDE.md still comes back with only a fraction of its nodes, I'm happy to dig in and add the truncation warning you suggested. Otherwise this can probably be closed.

  2. safishamsi commented on Sep 29, 2026

    @safishamsi
    Member

    Good first issue. _FILE_CHAR_CAP = 20_000 lives in graphify/llm.py and is applied in _read_files. The fix is to emit a warning (once per run, to stderr) when a file is truncated, so it is not silent. There is a recent warn-once pattern to mirror in graphify/detect.py (extract_pdf_text, the _pypdf_missing_warned flag). Add a test asserting the warning fires when a file exceeds the cap.

  3. AK-Lmn commented on Sep 29, 2026

    @AK-Lmn
    Contributor

    Hi! I'd like to work on this. I'll implement the warn-once pattern on stderr in _read_files\ mirroring _pypdf_missing_warned\ in \graphify/detect.py\ whenever a file exceeds _FILE_CHAR_CAP, and add unit tests to verify the warning behavior.

  4. safishamsi commented on Sep 30, 2026

    @safishamsi
    Member
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

    good first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions