graphify icon indicating copy to clipboard operation
graphify copied to clipboard

Semantic-extraction chunking is file-count-only, not density-aware — causes repeated 64k-output-token failures on doc-heavy corpora

Open AutogenousEngine opened this issue 3 months ago • 0 comments

Summary

SKILL.md Step 3 Part B / Step B1 chunks files into groups of "20-25 files each" purely by file count. On a corpus with uneven document density, this produces chunks that reliably blow the subagent's 64k output-token ceiling.

What happened

Running the default pipeline (subagent dispatch, no LLM API key) on a corpus of ~155 markdown docs + a handful of images, chunked at 20-25 files as instructed: 5 of 14 initial chunks failed with

API Error: Claude's response exceeded the 64000 output token maximum.

The failing chunks were consistently the ones containing narrative-dense files (multi-thousand-word engineering log / handoff-style docs, and one large schema-reference doc). Chunks of the same file count but lower density (READMEs, short compliance docs) succeeded fine at 20-25 files. Splitting the failing chunks down to 3-4 files each resolved every case.

Proposed fix

  • Chunk by an estimated word/character budget in addition to (or instead of) a flat file count — e.g. target ~15-25k words per chunk, capped at 25 files, whichever binds first.
  • Flag any single file above a size threshold (e.g. >8k words) to get its own chunk rather than being bundled with others.
  • Add an explicit instruction to references/extraction-spec.md's subagent prompt: "Keep your final response text to 2-3 sentences — do NOT paste the extracted JSON into your response, only write it via the Write tool." This alone should reclaim a large fraction of the 64k budget, since several failures looked like the subagent narrating/duplicating its findings in prose in addition to the Write call.
  • In Step B3 (collect/merge), when a chunk fails specifically with an output-token-limit error (this is a distinguishable error string), the skill should instruct: halve the file count and redispatch immediately, rather than the current "print a warning and skip that chunk — do not abort." A silent skip means real content is silently dropped from the graph unless the operator notices and manually retries, which is exactly what happened here across three successive dispatch rounds before I found a working chunk size.

AutogenousEngine avatar Aug 17 '26 22:08 AutogenousEngine