Skip to content

repomap: stop including prompt mentions in the repo-map cache key (fixes repeated full scans on huge repos) - #5556

Open
SnowingFox wants to merge 1 commit into
Aider-AI:mainfrom
SnowingFox:fix/5529-repomap-cache-key
Open

repomap: stop including prompt mentions in the repo-map cache key (fixes repeated full scans on huge repos)#5556
SnowingFox wants to merge 1 commit into
Aider-AI:mainfrom
SnowingFox:fix/5529-repomap-cache-key

Conversation

@SnowingFox

Copy link
Copy Markdown

Fixes #5529

Problem

On a repo the size of the Linux kernel, every request re-runs the full repo-map scan (~20 min each), making aider unusable. The map is cached, but the cache key in get_ranked_tags_map() includes mentioned_fnames/mentioned_idents whenever refresh="auto" is active:

if self.refresh == "auto":
    cache_key += [
        tuple(sorted(mentioned_fnames)) if mentioned_fnames else None,
        tuple(sorted(mentioned_idents)) if mentioned_idents else None,
    ]

Those prompt-derived values change on every request (the user mentions different files/identifiers each turn), so every request misses the cache and re-runs the expensive scan, even though the file set and file contents are unchanged.

Fix

Build the cache key only from the things the expensive scan actually depends on: the file set (chat_fnames + other_fnames) and the token budget. mentioned_fnames/mentioned_idents only affect per-request ranking personalization inside get_ranked_tags(); they do not change the underlying scan. Leaving them out of the key means the scan result is reused across prompts for an unchanged file set.

This matches the existing refresh="files" behavior, which has never put mentions in the key, and is consistent with the "auto" refresh intent: once a map is expensive to build, reuse it until the file set changes.

Verification

Added tests/basic/test_repomap.py::test_repo_map_auto_cache_not_polluted_by_mentions. It arms the refresh="auto" cache (simulating a slow first scan via map_processing_time) and asserts that a second request with different mentioned files/identifiers does not run the uncached scan again:

$ AIDER_ANALYTICS=false PYTHONPATH=. python -m pytest -q tests/basic/test_repomap.py -k test_repo_map_auto_cache_not_polluted_by_mentions -p no:cacheprovider
1 passed

The test fails against main (the second request re-runs the scan) and passes with this change. The existing repo-map tests (test_repo_map_refresh_files, test_repo_map_refresh_auto) are unaffected.

Notes

This is a small, localized change to the repo-map cache only; it does not touch other subsystems. No other open pull request in this repo is related.

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.

Any in teraction on huge repo (e.g. Linux kernel) triggers a repo scan

1 participant