Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Cache LLM model instances in registry#14

Closed
ishaanxgupta wants to merge 1 commit into
mainfrom
bolt-cache-model-registry-2149973887280083142
Closed

Cache LLM model instances in registry#14
ishaanxgupta wants to merge 1 commit into
mainfrom
bolt-cache-model-registry-2149973887280083142

Conversation

@ishaanxgupta

Copy link
Copy Markdown
Contributor

💡 What:
Added @lru_cache(maxsize=16) to the get_model function in src/models/registry.py.

🎯 Why:
The get_model function was creating a new LLM client instance on every call. Instantiating these clients can be expensive (setting up connections, validating keys). By caching the result, we reuse the same client instance for the same configuration (provider, model_name, temperature).

📊 Impact:
Reduces unnecessary object creation and potential connection overhead. While strict benchmarking wasn't possible due to environment constraints, this is a standard optimization for service clients.

🔬 Measurement:
Verified using a reproduction script that get_model now returns the same instance for identical arguments. Existing unit tests passed.


PR created automatically by Jules for task 2149973887280083142 started by @ishaanxgupta

Optimizes `get_model` by caching LLM client instances to avoid redundant instantiation.
Verified with reproduction script and existing tests.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@ishaanxgupta ishaanxgupta changed the title ⚡ Bolt: Cache LLM model instances in registry Cache LLM model instances in registry Feb 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant