Skip to content

save_semantic_cache silently drops entries when the adaptive-retry split path produces a malformed source_file (weak/local backends) — distinct from #1991 #2973

Closed

Description

@wyadvd-dotcom

Environment: graphifyy 0.9.48, --backend openai pointing at a self-hosted llama.cpp server (gemma-4-26b-a4b via OpenAI-compatible endpoint), --max-concurrency 1 --api-timeout 300.

Not the #1991 scenario: our invocation doesn't pass --out at all — root and cache_root correctly resolve to <corpus> and <corpus>/graphify-out respectively (confirmed by reading save_semantic_cache's docstring and the _checkpoint_chunk call site in llm.py, which already does the root/cache_root split #1991 introduced). So this isn't a root-anchoring misconfiguration.

What actually happens: during a long incremental extract run, whenever a chunk is too large for the model's practical context and _extract_with_adaptive_retry bisects it (llm.py, "chunk of N exceeded context... splitting in half and retrying"), the resulting sub-chunk's extracted nodes sometimes carry a source_file string that doesn't resolve to a real file. save_semantic_cache then hits its skipped_not_file == len(by_file) branch and discards the whole group, with only the generic "paths do not resolve..." warning pointing at the wrong (already-fixed) issue number. Log excerpt:

[graphify] chunk of 360 exceeded context at depth 0 (BadRequestError); splitting in half and retrying
[graphify extract] chunk 219/1205 done
.../graphify/llm.py:2595: RuntimeWarning: save_semantic_cache: all 20 source_file group(s) were
skipped because their paths do not resolve to real files. This usually means root is anchored
to the wrong directory (see the closed root-cause issue above).

Net effect for us: an "incremental" nightly extraction over a ~1200-chunk vault was silently re-attempting large already-processed chunks every run, because their split-path results never made it into the cache. Ran 14h42m stuck at 18% before we killed it.

Suspected root cause: the model's self-reported source_file field (trusted as-is, no deterministic cross-check against the real dispatched file list) drifts specifically under the split/retry path, likely because a weaker/local model re-prompted with a reduced file subset loses track of which of the original chunk's files a given node came from.

Fix we tested and are running locally (in save_semantic_cache, cache.py): when resolved_source_path(fpath) fails to resolve to a real file, and allowed_paths is available (it already is at the only real caller, _checkpoint_chunk, via allowed_source_files=[unit_path(item) for item in chunk]), fall back to an unambiguous basename match against that known-good, already-dispatched file list. Only recovers when exactly one candidate matches; any ambiguous or genuinely-bogus path still falls through to the existing skip behavior unchanged.

if not p.is_file() and allowed_paths is not None:
    candidates = [ap for ap in allowed_paths if ap.name == Path(fpath).name]
    if len(candidates) == 1:
        cache_path = candidates[0]
        p = candidates[0]
if p.is_file():
    ...

Verified locally with three synthetic cases: (1) a malformed-but-basename-unique path recovers correctly, (2) an ambiguous basename (two allowed files sharing a name) correctly stays skipped, (3) normal well-formed paths with no allowlist are unaffected — no regression. Happy to open a PR with this and a regression test if useful.

Activity

  1. safishamsi commented on Sep 15, 2026

    @safishamsi
    Member

    Fixed in v0.9.62 (on PyPI) via #3553, thanks @ayushcodes10. Thanks for the report!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions