perf(code_execution): cache tools in ExtensionManager#6433
Merged
alexhancock merged 1 commit intoblock:mainfrom Jan 12, 2026
Merged
perf(code_execution): cache tools in ExtensionManager#6433alexhancock merged 1 commit intoblock:mainfrom
alexhancock merged 1 commit intoblock:mainfrom
Conversation
…ed MCP calls When code execution is enabled, every execute_code/read_module/search_modules call was fetching tools from ALL MCP servers, causing significant latency. Changes: - Add tools_cache field to ExtensionManager (Arc<Vec<Tool>> to avoid cloning) - Cache is populated on first get_prefixed_tools call - Cache is invalidated after extensions are modified - Version counter (AtomicU64) prevents stale cache from concurrent fetch/invalidate races - Fix CancellationToken reuse in pagination loop (pre-existing bug) This reduces the overhead from O(N) network calls per code execution to O(1) after the initial cache population. Signed-off-by: rabi <ramishra@redhat.com>
Contributor
Author
|
@alexhancock PTAL, I can see good improvement with this when using code mode. |
alexhancock
approved these changes
Jan 12, 2026
Collaborator
alexhancock
left a comment
There was a problem hiding this comment.
Nice improvement, thanks!
fbalicchia
pushed a commit
to fbalicchia/goose
that referenced
this pull request
Jan 13, 2026
Signed-off-by: rabi <ramishra@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When code execution is enabled, every execute_code/read_module/search_modules call was fetching tools from ALL MCP servers, causing significant latency.
Changes:
This reduces the overhead from O(N) network calls per code execution to O(1) after the initial cache population.
Type of Change
AI Assistance
Testing
Unit tests added and locally tested.