[Bug]: gemini silently omits most files in a single oversized chunk (token_budget=60000 default) — not truncation
Pre-flight
- [x] I have checked the Troubleshooting section in the README
What happened?
extract_corpus_parallel() defaults to token_budget=60_000. With a
doc-heavy corpus that packs every dispatched document into a single chunk,
and gemini-3-flash-preview then returns a syntactically valid response that
covers only a fraction of the files. graphify detects this correctly and warns:
[graphify extract] semantic extraction on 30 files via gemini...
[graphify extract] chunk 1/1 done
[graphify] WARNING: 24/30 dispatched file(s) produced no nodes and are absent
from the graph: copilot-instructions.md, opencode.yml, CONTRIBUTING.md, ...
The model returned a response but omitted them; a re-run will retry them.
[graphify extract] semantic extraction is incomplete: 24 dispatched file(s)
produced no nodes and 0 came back truncated or hollow.
The important detail is that final clause: 0 truncated, 0 hollow. The response is complete and well-formed — it just silently omits 24 of the 30 files. The whole-corpus single chunk is what triggers it.
Two things then compound:
- A re-run "retries them" — which re-sends the same oversized chunk, which omits the same files. That loop is what presents to users as the semantic index never finishing, rather than as a coverage bug.
- With library defaults (600 s/request, 6 SDK retries on 429, bisect depth 3) a single worst-case chunk can burn ~80 minutes with no stage-level ceiling.
The README Troubleshooting entry for "extraction was incomplete ... refusing to
overwrite" attributes this to the model's output-token limit being "cut off
mid-string", and calls the warnings "noisy but not data loss". That diagnosis
doesn't match this case — output was 1,899 tokens, nowhere near a cap, and
graphify explicitly reports nothing truncated. The advice to lower
--token-budget is still correct and does fix it, so credit where due; but the
stated cause sends you looking for an output-cap problem that isn't there.
Steps to reproduce
30 markdown/config documents (24 MB repo, 213 code files — code is AST-only and never reaches the model). Only chunking changes between the two runs:
# Arm A — library default
graphify extract . --backend gemini --model gemini-3-flash-preview --force \
--max-concurrency 1 --api-timeout 180
# Arm B — only difference is chunk size
graphify extract . --backend gemini --model gemini-3-flash-preview --force \
--max-concurrency 1 --api-timeout 180 --token-budget 15000
Error output or graph output
--token-budget |
chunks | docs with no nodes | input tok | output tok |
|---|---|---|---|---|
| 60000 (default) | 1 | 24 / 30 | 59,989 | 1,899 (3.2%) |
| 15000 | 4 | 3 / 30 | 62,425 | 9,068 (14.5%) |
Identical corpus, identical model, ~62K input tokens both arms — output rose 4.8x purely from splitting. Coverage went 20% → 90%.
A cheap pre-flight health signal that found this: the output:input token
ratio in graphify-out/cost.json. Backtracking through my own run history,
every run that "never finished" sat at 3–8%; every healthy run sat at 35–65%.
Graphify version
0.9.75
Operating System
Linux
Anything else?
- Not model-specific in the sense of quality —
gpt-oss:120bvia Ollama cloud did not show this collapse at a similar chunk size, butgpt-oss:20bandgranite4.2did produce hollow/prose output in earlier testing. The common factor looks like chunk size. - The README's own remedy example uses
--token-budget 4000, which is further in the direction that works. - Possible improvements, if useful:
- Lower the default
token_budget, or derive it from corpus size rather than a fixed 60K. - When files are omitted but the response is not truncated, say so explicitly — "the model returned a short but valid response; N files were not addressed" is far more actionable than a retry that cannot succeed.
- Consider capping retries for this specific case, since retrying an unchanged chunk against the same model reproduces the same omission.
- Lower the default
Happy to provide the corpus or test harness if useful.
Thanks for opening this issue, @jkemp814. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
This is a significant bug. When Gemini silently omits files in an oversized chunk, the knowledge graph becomes incomplete without any warning, leading to incorrect query results.
Root cause hypothesis: The chunking logic likely has a token_budget check that skips files exceeding the threshold, but doesn't log or warn about the omission. The 60K default may be too conservative for Gemini's actual context window.
Suggested fixes:
- Log omitted files: When a file exceeds token_budget, log a warning with file path and size
- Auto-split large files: Instead of omitting, split large files into multiple chunks that fit within budget
- Configurable budget: Allow users to set token_budget per provider/model
- Validation step: After chunking, verify total files processed vs total files in repo
Quick diagnostic: Can you check if the omitted files appear in the chunking logs with a 'skipped' or 'omitted' status? That would confirm the silent drop behavior.
Validated this live with gemini-3-flash-preview on a synthetic 30-doc corpus (about 65K tokens, mirroring the reported setup), running the exact arms from the issue with --max-concurrency 1.
Results: could not reproduce the 24/30 omission. The forced single-chunk arm covered 30/30 files on uniform docs (25 percent out:in ratio) and 29/29 dispatched files on a diverse mixed md/yml set (6 percent ratio). So the collapse does not appear deterministic on chunk size alone. It likely depends on dense entity-rich docs, or the preview model has shifted since the report.
Two observations in support of the proposed fixes. First, the diverse single-chunk run landed at 6 percent output ratio, squarely in the reported sick band, presenting as thin coverage (about 1 node per file) rather than dropped files, so the ratio signal looks real. Second, from code the retry concern checks out: omission without truncation re-sends the identical chunk, which cannot succeed on its own.
Supporting the proposed changes (explicit short-but-valid message plus capped retries on non-truncated omissions) even without a full repro. Happy to re-run against the original corpus if it can be shared.
@jkemp814 @nothariharan @belentani7 @jippi @teemow I'd like to work on this. I've traced it in v8:
- When a chunk comes back complete (not truncated, not hollow) but some files are missing, there's no retry. _extract_with_adaptive_retry treats it as a success, and the files are only reported through uncovered_files.
- A re-run without --force re-sends only the missing files. With a doc-heavy corpus, though, those still fit in a single 60K chunk, so the same omission is likely to happen again.
- The README has no troubleshooting entry for "N files produced no nodes, 0 truncated or hollow". The output-token explanation is under the invalid-JSON entry.
I'd split this into two PRs:
- Diagnostics (small). When files are missing and nothing was truncated or hollow, say so directly: "the model returned a short but valid response; N files were not addressed". Suggest a smaller --token-budget, and add a README troubleshooting entry. I'll build on #3617 so we don't conflict.
- Retry (follow-up). Inside the same run, re-send only the missing files in smaller sub-chunks, limited by the existing retry depth (no retries when the depth is 0). This adds cost, so I'd like your OK on the approach before I write it.
I'm leaving the default token_budget unchanged, since it affects every user and the omission hasn't been reproduced consistently. Happy to change that if you'd rather lower it.
@pranavkrishnadanda imo after running this live i'm not fully convinced there's a systematic bug here my single-chunk runs covered everything (30/30 and 29/29), so the big omission seems more like model flakiness on a specific corpus than something chunking deterministically causes. your own note that it hasn't been reproduced consistently kind of says the same thing
so from my side: diagnostics PR gets a yes, it's small, cheap, and that "short but valid" message helps regardless. the retry one i'd hold off on, it adds real cost and complexity for a failure mode nobody can reliably trigger yet. and fully agree on leaving the default alone
maybe land diagnostics first and see if better messages surface an actual reproducible case, then the retry design has something concrete to target
Thanks for running it live, that's a fair point. Since neither of us could reproduce the 24/30 omission, I'll limit this to diagnostics and leave the retry design until better messages turn up a case we can reproduce.
Scope for the PR:
- When files are missing and nothing came back truncated or hollow, print a separate message: "the model returned a short but valid response; N file(s) were not addressed". Suggest a smaller --token-budget instead of only saying "a re-run will retry them".
- Include the run's output:input token ratio in that message. Your 6% single-chunk run suggests it's a useful signal even when files aren't dropped outright.
- Add a README troubleshooting entry for "produced no nodes, 0 truncated or hollow", separate from the output-token explanation in the invalid-JSON entry.
- Regression tests in tests/test_chunking.py and tests/test_hollow_chunks_arm_shrink_guard.py, building on #3617 so the two PRs don't conflict.
- The default token_budget stays as it is.
@safishamsi could you assign this to me? I can have the PR up within [2–3 days].
Thanks both — and thanks @pranavkrishnadanda for tracing it in v8; your read matches mine.
Direct answer to @nothariharan's question: the omitted files do not get a skipped/omitted status anywhere in the chunking log. There is no per-file marker at chunk time. The only signal is a post-parse warning, and that warning is lossy — it prints the first 5 names, then (+N more). So the printed log fundamentally cannot enumerate the set. I recovered the full lists by diffing the dispatch list (files.document in graphify-out/.graphify_incremental.json) against the source_file values written into graph.json. Emitting the full uncovered list (or dumping it to a file) would be the single most useful part of the diagnostics PR.
Setup
graphify 0.9.75, gemini-3-flash-preview, Linux. Scan: 213 code (AST-only, never sent to the model), 30 documents, 89 unclassified, 4 ignored. Only the chunk budget differs between arms.
# Arm A — library default (60000)
graphify extract . --backend gemini --model gemini-3-flash-preview --force \
--out /tmp/opencode/gf-gemini --max-concurrency 1 --api-timeout 180
# Arm B — only token-budget differs
graphify extract . --backend gemini --model gemini-3-flash-preview --force \
--out /tmp/opencode/gf-gemini-tb15k --max-concurrency 1 --api-timeout 180 \
--token-budget 15000
Arm A — default token_budget=60000
chunk 1/1 done; 24/30 produced no nodes, 0 truncated, 0 hollow; 59,989 in / 1,899 out (3.2%); wrote 901 nodes / 1307 edges / 187 communities. Full omitted set (the 5 in the warning are the first five in dispatch order):
.github/copilot-instructions.md
.github/workflows/opencode.yml
CONTRIBUTING.md
MARKDOWN_CHEATSHEET.md
MISC/BIN-CLEANUP-PLAN.md
MISC/agent-scripts/README.md
MISC/agent-scripts/git-sync-cheatsheet.md
README.md
SKILLS.md
bookmarks-config.yaml
borgbackup/laptop.md
opencode-cloud/raw/README.md
opencode-cloud/sparse/README.md
podman/ai-stack/README.md
podman/ai-stack/README.ollama-pascal-cuda.md
podman/clamav/daemon.yml
podman/clamav/scan.yml
podman/searxng-standalone/settings.yml
podman/searxng/Instructions_for_setting_up_searxng_with_systemd.md
podman/searxng/chat-summary-firefox-openwebui-searxng.md
podman/searxng/searxng-openwebui-podman-quadlet-session-notes.md
podman/searxng/searxng-podman-quadlet-openwebui-setup.md
podman/toolbox/README.md
sync_home_bi.README.md
The only 6 docs that survived Arm A: AGENTS.md, COMPACTION.md, CONTEXT.md, HISTORICAL.md, LANGUAGE.md, tools.yaml.
Arm B — --token-budget 15000
chunk 1/4 … 4/4 done; 3/30 produced no nodes, 0 truncated, 0 hollow; 62,425 in / 9,068 out (14.5%); wrote 931 nodes / 1325 edges / 206 communities. Full omitted set:
CONTRIBUTING.md
MISC/agent-scripts/git-sync-cheatsheet.md
podman/searxng-standalone/settings.yml
--token-budget |
chunks | docs omitted | input tok | output tok | nodes |
|---|---|---|---|---|---|
| 60000 (default) | 1 | 24 / 30 | 59,989 | 1,899 (3.2%) | 901 |
| 15000 | 4 | 3 / 30 | 62,425 | 9,068 (14.5%) | 931 |
Reproducibility
Not a one-off. A second 15000 run omitted a different set of 4 — CONTRIBUTING.md, bookmarks-config.yaml, podman/searxng/searxng-podman-quadlet-openwebui-setup.md, settings.yml — and the per-host fleet rebuilds each omitted 2–4. So the 15000 residual is a nondeterministic tail, not a fixed floor. CONTRIBUTING.md and MISC/agent-scripts/git-sync-cheatsheet.md were omitted on every run at every budget; everything else moves around.
Out-of-scope misattribution (separate — #1895)
Both arms also drop nodes the model attached to files that weren't dispatched for semantic extraction. Arm A, complete (5 nodes / 5 files):
Makefile, common.sh, fleet-sync-repos.sh, system-update.sh, toggle-stack.sh
Arm B truncated too: 15 nodes, named ai-stack-ollama.container, ai-stack-open-webui.container, ai-stack-searxng.container, ai-stack.pod, bootstrap-agent-files.sh (+9 more). Flagging so you can ignore it when reading the doc-coverage numbers — it's not the same failure.
Skips-by-design (not the bug, for completeness)
- 89 files unclassified (no supported extension/shebang) → skipped, listed in full below.
- 2 code files yielded no symbols:
MISC/agent-scripts/opnsense-apply-geoip-allowlist.php,bookmark_scripts/pyproject.toml. Adding.markdownlint.jsonand the four.vscode/*.json, 5 code/config files contributed no nodes.
89 unclassified / skipped files
.editorconfig
.gitallowed
.gitattributes
.github/CODEOWNERS
.github/TEAM_MEMBERS
.gitignore
.graphifyignore
.markdownlintignore
.megaignore
.opencode-mem-project
.prettierignore
.prettierrc
.shellcheckrc
Firefox/Desktop/firefox-nvidia.desktop
Firefox/Desktop/firefox.desktop
LICENSE
UPDATE/appimage_sources.conf
podman/.gitignore
podman/ai-stack/Containerfile.ollama-cc61
podman/ai-stack/Makefile
podman/ai-stack/quadlet/ai-stack-model-loader.container
podman/ai-stack/quadlet/ai-stack-ollama.container
podman/ai-stack/quadlet/ai-stack-open-webui.container
podman/ai-stack/quadlet/ai-stack-vllm.container
podman/ai-stack/quadlet/ai-stack.pod
podman/clamav/clamd-daemon.conf
podman/clamav/clamd.conf
podman/monit/Containerfile
podman/monit/monit.container
podman/searxng-standalone/searxng-standalone.container
podman/searxng/ai-stack-searxng.container
podman/searxng/ai-stack.pod
podman/toolbox/Containerfile
podman/toolbox/Makefile
ruff.toml
security/keyring-manifest.tsv
systemd/atuin-prune-weekly.service
systemd/atuin-prune-weekly.timer
systemd/borg-backup-dell-7740.service
systemd/borg-backup-dell-7740.timer
systemd/borg-backup-hp-z840.service
systemd/borg-backup-hp-z840.timer
systemd/borg-backup-origin-p170em.service
systemd/borg-backup-origin-p170em.timer
systemd/btrfs-maintenance-hp-z840.service
systemd/btrfs-maintenance-hp-z840.timer
systemd/btrfs-scrub-after.service
systemd/btrfs-scrub-after.timer
systemd/clamav-scan-fail.service
systemd/clamav-scan.service
systemd/clamav-scan.timer
systemd/fetch-geoip-allowlist.service
systemd/fetch-geoip-allowlist.timer
systemd/git-maintenance-monthly.service
systemd/git-maintenance-monthly.timer
systemd/git-maintenance-weekly.service
systemd/git-maintenance-weekly.timer
systemd/link-units.service
systemd/link-units.timer
systemd/mega-cmd.service
systemd/nfs-automount-trigger.service
systemd/ollama-tunnel-hp-z840.service
systemd/ollama-tunnel-origin-p170em.service
systemd/ollama.service
systemd/open-webui-standalone-dell-7740.service
systemd/open-webui-standalone-dell-7740.service.path
systemd/open-webui-standalone-hp-z840.service
systemd/open-webui-standalone-hp-z840.service.path
systemd/open-webui-standalone-origin-p170em.service
systemd/open-webui-standalone-origin-p170em.service.path
systemd/open-webui-standalone.service
systemd/open-webui.service
systemd/opencode-mem-sync-dell-7740.service
systemd/opencode-mem-sync-dell-7740.timer
systemd/opencode-mem-sync-origin-p170em.service
systemd/opencode-mem-sync-origin-p170em.timer
systemd/system-updates-weekly.service
systemd/system-updates-weekly.timer
systemd/update-cargo.service
systemd/update-cargo.timer
systemd/update-pip-host.service
systemd/update-pip-host.timer
systemd/update-rustup.service
systemd/update-rustup.timer
systemd/update-standalone-bins.service
systemd/update-standalone-bins.timer
systemd/update-toolboxes.service
systemd/update-toolboxes.timer
vscode_scripts/setup_vscode_portable_windows.bat
Caveats, for accuracy
- The
gpt-oss:120b-cloudcomparison in my original report is weaker than I stated. The run I have for it was 6 docs, 34,202 in / 18,960 out (55%), no omission — a much smaller single chunk, not the same 30-doc payload. Treat "cloud model doesn't collapse" as unproven, not a falsification. (gpt-oss:20bandgranite4.2did produce hollow output earlier, but those weren't controlled same-corpus runs either.) - Both
WARNINGlines cap at 5 names +(+N more). Everything above came fromgraphify-out/.graphify_incremental.json(files.document) intersected with the written graph, not from the log. - The ratio signal still holds: every collapsed run sat at 3.2–8% output:input; healthy runs at 35–65%.
Happy to share the corpus or the exact harness.
Follow-up with a third arm — this refines the "chunk size vs model" question.
I re-ran the same Scripts corpus through a different model at the default token_budget=60000. Result: the oversized single chunk is not what breaks it — the model is.
| backend / model | --token-budget |
chunks | docs omitted | input tok | output tok | ratio | nodes |
|---|---|---|---|---|---|---|---|
| gemini-3-flash-preview | 60000 | 1 | 24 / 30 | 59,989 | 1,899 | 3.2% | 901 |
| gemini-3-flash-preview | 15000 | 4 | 3 / 30 | 62,425 | 9,068 | 14.5% | 931 |
| deepseek-v4-flash | 60000 | 1 | 0 / 30 | 56,439 | 16,423 | 29.1% | 945 |
deepseek-v4-flash covered all 30 files in a single ~56K-token chunk — no produced no nodes warning was emitted, and I verified 30/30 present by diffing the dispatch list against source_file in the written graph.json. Every one of the 24 files gemini omitted at the same budget is present here.
So the collapse is model-specific coverage behavior on a large multi-file chunk, not a deterministic property of the chunk size. That is consistent with @nothariharan's finding that it isn't deterministic on chunk size alone, and with gpt-oss:120b-cloud not collapsing — but now with a clean same-30-doc, same-default-budget comparison instead of a smaller payload.
Notes on the third arm
- It's not a stock graphify backend. The endpoint is OpenCode Go (
https://opencode.ai/zen/go/v1), registered as a custom provider in~/.graphify/providers.json; it needs anx-opencode-sessionheader that graphify can't currently set natively (worked around viaOPENAI_CUSTOM_HEADERS; filed as #3680). So treat this as "a different frontier model on the identical chunk," not as a supported-backend benchmark. - Not a byte-identical replay. The gemini arms were graphify 0.9.75; this arm is 0.9.77, and the repo scanned as 217 code / 30 docs vs 213 code / 30 docs in October. Doc content may have drifted slightly. The coverage result (0/30 omitted) is unambiguous; the raw token/node counts are approximate.
- The cost line reported
$0.0000(subscription allowance), so this path is cheap to reproduce if useful to the maintainers.
If either of you wants, I can re-run the gemini arms on 0.9.77 to make it a fully controlled three-way — same binary, same repo state, only --backend/--model and --token-budget varying.
Controlled three-way, all on graphify 0.9.77, same repo state (217 code / 30 docs), same dispatch list — only --backend/--model and --token-budget vary. Omission counts verified by diffing the dispatch list against source_file in each written graph.json, not just the warning text.
| backend / model | --token-budget |
chunks | docs omitted | input tok | output tok | ratio | nodes |
|---|---|---|---|---|---|---|---|
| gemini-3-flash-preview | 60000 | 1 | 24 / 30 | 60,799 | 1,873 | 3.1% | 915 |
| gemini-3-flash-preview | 15000 | 4 | 2 / 30 | 63,235 | 8,658 | 13.7% | 942 |
| deepseek-v4-flash (opencode-go) | 60000 | 1 | 0 / 30 | 56,439 | 16,423 | 29.1% | 945 |
Conclusions on a single binary/repo state:
- The default-60000 collapse is reproducible and version-independent: 24/30 on 0.9.75 (3.2%) and 24/30 on 0.9.77 (3.1%). It is a property of
gemini-3-flash-previewon the oversized chunk, not a graphify regression between those versions. - There is a small version effect in the residual tail: the 15000 arm dropped 2/30 on 0.9.77 vs the 3–4 seen on 0.9.75. The only files that survive every run at every budget are
CONTRIBUTING.mdandMISC/agent-scripts/git-sync-cheatsheet.md. - A different frontier model (
deepseek-v4-flash) covers all 30 files in a single ~56K-token chunk at the default budget. So "one oversized chunk" is a necessary but not sufficient condition — the model's attention over a large multi-file chunk is the deciding variable.
Same caveat as the earlier third arm: the opencode-go endpoint is a custom provider with an x-opencode-session header requirement (#3680), not a stock graphify backend. Commands are otherwise identical to the original arms, and the cost is trivial to reproduce if useful.
@belentani7 — I tested that one directly, and I think "60K is too conservative for Gemini's context window" is the direction that doesn't apply here. Raising it changes nothing:
--token-budget |
chunks | docs omitted | input | output |
|---|---|---|---|---|
| 60000 | 1 | 24 / 30 | 60,799 | 1,873 |
| 150000 | 1 | 24 / 30 | 60,799 | 1,873 |
The whole 30-doc corpus is ~60K input tokens, so it already packs into a single chunk at the default — i.e. at 60K the packer is cramming all 30 small files into one request. token_budget is a chunk-packing cap, not a context-window cap, so raising it can't go below one chunk, and the single chunk is exactly the failing shape. Gemini's context is ~1M, so context was never the limit (graphify also reports 0 truncated).
The direction that works is the opposite: --token-budget 15000 → 4 chunks → 2/30 omitted.
I also checked the thinking budget (reasoning_effort is hardcoded low for gemini): forcing high moved 24→17 omitted, still collapsing. Max-output was never binding (cap 16,384, used 1,873). So the deficit isn't budget/context in any of the three senses — it's the model's coverage over one oversized multi-file chunk. The rest of your list (log omitted files, per-provider budget, post-chunk validation) is exactly on target.
Third validation arm from my side, dense entity-rich corpus this time (30 runbooks, about 72K input tokens in one chunk, the closest I could get to your setup synthetically): 30/30 files covered, 30 nodes, 72,619 in / 2,814 out (3.9%). Same picture as before. Thin output in the sick band, zero omission. Three corpora, zero reproductions of the 24/30 drop, which supports the refined conclusion that the chunk is necessary but not sufficient.
One code-level confirmation for the diagnostics scope: your logging claim checks out exactly. The warning caps at 5 names (llm.py), while the full uncovered_files list is built in the same function but lives only in memory and is consumed for the shrink guard (cli.py), never persisted. So post-run the full omitted set is unrecoverable except by the dispatch-vs-graph diff you described. Dumping that list to a file is a precise small win and I would put it first in the diagnostics PR.
Happy to re-run on your corpus if you share it. That is the one validation none of us can do synthetically.
Corpus is up, ready to run: https://github.com/jkemp814/graphify-4101-repro
The 30 docs at their original relative paths, lightly redacted (hostnames → host-a/b/c, LAN IPs → 192.0.2.x, one credential literal) — content otherwise verbatim. The CI workflow was moved to the repo root as opencode-workflow.yml so the public copy runs no GitHub Actions, and REPRO (extensionless, so graphify skips it as unclassified) has the exact commands and the expected 24/30.
Estimated cost for both arms on a paid Gemini key: ~$0.04 (60000) + ~$0.06 (15000), with --max-concurrency 1 --api-timeout 180 on graphify 0.9.77.
One thought on why synthetics may miss it: this corpus is 30 heterogeneous small files — mixed .md and .yml, ~190 KB, ~60K tokens, real docs with wildly varying structure — not uniform runbooks or a dense entity-rich set. If the trigger is many small mixed-type files packed into one chunk (rather than density or raw size), that's the variable to vary. Happy to produce a scrambled/renamed or size-shuffled variant of the same 30 if it would help isolate what actually flips it.
Fixed in 0.9.85 (now on PyPI) via #4280. Thanks @ayushcodes10!