Skip to content

fix: cache batched LLM clustering responses for resume on failure - #163

Merged
anhnh2002 merged 6 commits into
FSoft-AI4Code:mainfrom
BrahmendraBachi:feat/cache-batch-cluster-response
Nov 16, 2026
Merged

anhnh2002 merged 6 commits into
FSoft-AI4Code:mainfrom
BrahmendraBachi:feat/cache-batch-cluster-response

Conversation

@BrahmendraBachi

Copy link
Copy Markdown
Contributor

fix: cache batched LLM clustering responses for resume on failure

Summary

Large repositories often trigger multi-batch LLM module clustering: the dependency graph is split into several batches, and each batch gets its own clustering call. If a run fails partway through (network error, rate limit, process kill), earlier batches are wasted and must be re-requested from the LLM.

This change persists successful batch results on disk and reuses them on retry, then cleans up the cache once clustering finishes and the module tree is saved.

Problem

  • Clustering can require many sequential LLM calls (one per batch).
  • A failure on batch N forces re-running batches 1 … N−1 even though their outputs were already valid.
  • That increases cost, latency, and the chance of repeated failures.

Solution

  1. Persist each successful multi-batch partial module tree to
    docs/temp/clustering_batch_cache.json.
  2. Key entries by:
    • Scope — which cluster_modules invocation (e.g. __root__, auth/login).
    • Batch index — 1-based index in the current multi-batch pass.
    • Component set — fingerprint of the batch's node IDs (order-independent).
  3. On retry, cluster_modules looks up each batch before calling the LLM; cache hits are merged into the running module tree.
  4. After success, when the module tree is written (first_module_tree.json / module_tree.json), delete the cache file (CLI adapter and backend documentation generator).

@BrahmendraBachi
BrahmendraBachi force-pushed the feat/cache-batch-cluster-response branch from 08c8027 to 872f954 Compare November 15, 2026 14:31
@anhnh2002
anhnh2002 merged commit 8c07821 into FSoft-AI4Code:main Nov 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants