Reduce MCP review latency via shared changed-file resolution + bounded auto-detection#457
Reduce MCP review latency via shared changed-file resolution + bounded auto-detection#457Bakul2006 wants to merge 1 commit into
Conversation
|
Hey @tirth8205 Just tried adding the Cache memory In the MCP Calls To improve the latency please review if the approach is correct or I should think of another way . Core idea is to make the MCP calls Stateful in some way. |
|
I reviewed this for v2.3.4 and deferred it. The latency problem is real, but the shared changed-file cache adds state across tools and increases the integration risk. The release instead shipped bounded detect-changes behaviour and compact architecture output. This PR should be revisited separately, ideally with clear cache invalidation rules and tests around stale graph state. |
|
Hey @tirth8205 thanks for the review I understand this is a complex logic for now And needs a defined structure for this to be implemented for now I will try to make a detailed explaination of my approach within 2-3 days. |
Clear Graphical Approach Of Shared Memory CacheThis is the usual flow of the code-review graph |



Issue #262
What Changed
New shared resolver
Added:
in:
This centralizes changed-file resolution for all review-oriented tools.
Resolution order:
changed_filesThe resolver returns both resolved files and metadata:
Bounded auto-detection
Auto-detection is now intentionally bounded.
Default timeout:
(configurable)
Instead of allowing long-running internal detection paths to stall MCP workflows, the resolver now fails fast and returns structured guidance.
This prevents multi-minute hangs during agent execution.
Short-lived shared cache
Added a thread-safe changed-file cache with configurable TTL.
Default TTL:
(configurable)
This allows consecutive MCP tool calls in the same review workflow to reuse resolved changed files instead of repeatedly invoking git detection logic.
This is especially beneficial for agent orchestration patterns where multiple tools are called back-to-back.
Wired Into Review Tools
The shared resolver is now used by:
detect_changes_func()get_review_context()get_affected_flows_func()get_impact_radius()get_minimal_context()This keeps behavior consistent across review flows.
User-Facing Behavior
When automatic changed-file detection exceeds the configured timeout and no files are resolved, tools now return explicit guidance indicating that callers should provide
changed_filesdirectly for fast execution.This replaces previous silent stalls / timeout-heavy behavior.
Configuration
New environment variables:
These can be tuned per environment / deployment.
Performance Impact
Expected improvements: