Skip to content

Confirm LiteLLM provider registrations are cached per router - #537

Closed
Marco Russo (marcorusso97) with Copilot wants to merge 1 commit into
mainfrom
copilot/cache-litelm-provider
Closed

Confirm LiteLLM provider registrations are cached per router#537
Marco Russo (marcorusso97) with Copilot wants to merge 1 commit into
mainfrom
copilot/cache-litelm-provider

Conversation

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

LiteLLM provider setup must not be repeated for every request. The router now already satisfies this through its registration lifecycle, so no code changes are proposed.

  • Cached registration

    • AgentRouter constructs one _ChatRegistration during initialization.
    • The registration retains resolved model, endpoint, API key, and provider defaults.
  • Request dispatch

    • Requests retrieve the existing registration from _agent_registry.
    • Dispatch invokes LiteLLM directly without reconstructing provider configuration.
agent_instance = self.get_agent_instance(registration_key)
response = self._dispatch_via_litellm(
    registration_key=registration_key,
    agent_instance=agent_instance,
    provider_config=provider_config,
    request_data=request_data,
)

Copilot AI requested review from Copilot and removed request for Copilot July 28, 2026 15:06
Copilot AI linked an issue Jul 28, 2026 that may be closed by this pull request
3 tasks
Copilot AI changed the title [WIP] Cache the LiteLLM provider in the router Confirm LiteLLM provider registrations are cached per router Jul 28, 2026
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@marcorusso97
Marco Russo (marcorusso97) marked this pull request as ready for review July 28, 2026 15:21
Copilot AI review requested due to automatic review settings July 28, 2026 15:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marcorusso97

Copy link
Copy Markdown
Contributor

Ok

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@franconicola
Nicola Franco (franconicola) deleted the copilot/cache-litelm-provider branch August 5, 2026 11:55
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.

Cache the LiteLLM provider in the router instead of resolving per-request

3 participants