Skip to content

feat: support injecting custom LLM clients into Gemini and AnthropicLlm#5035

Open
brucearctor wants to merge 4 commits intogoogle:mainfrom
brucearctor:feature/5027-custom-client
Open

feat: support injecting custom LLM clients into Gemini and AnthropicLlm#5035
brucearctor wants to merge 4 commits intogoogle:mainfrom
brucearctor:feature/5027-custom-client

Conversation

@brucearctor
Copy link
Copy Markdown

@brucearctor brucearctor commented Mar 28, 2026

Enable injecting pre-configured LLM clients into Gemini and AnthropicLlm models to support multi-agent systems with distinct configurations. Addresses #5027.

Testing Plan

I have verified these changes with the following:

Automated Tests

  • New Unit Tests: Added which specifically mocks the and clients to verify they are correctly consumed by the cached properties.
  • Regression Testing: Ran all 86 existing unit tests in and to ensure legacy behavior via environment variables is preserved.

Manual Verification

  • Pydantic Validation: Verified model initialization with actual and objects to ensure no runtime Pydantic resolution errors ().

Verification Command

uv run pytest tests/unittests/models/test_custom_client.py
uv run pytest tests/unittests/models/test_google_llm.py tests/unittests/models/test_anthropic_llm.py

@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Mar 28, 2026

Response from ADK Triaging Agent

Hello @brucearctor, thank you for your contribution!

To help reviewers better understand and verify your changes, could you please add a testing plan section to your PR description? This should describe how you've tested the changes, including any manual end-to-end tests you've performed.

You can find more details in our contribution guidelines.

Thanks!

@adk-bot adk-bot added the models [Component] Issues related to model support label Mar 28, 2026
@rohityan rohityan self-assigned this Mar 30, 2026
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Mar 30, 2026
@rohityan
Copy link
Copy Markdown
Collaborator

Hi @brucearctor , Thank you for your contribution! We appreciate you taking the time to submit this pull request.
Please address the review comments.

@brucearctor
Copy link
Copy Markdown
Author

Hi @brucearctor , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please address the review comments.

looking into them

- Move Client import to TYPE_CHECKING, remove duplicate top-level import
- Exclude client field from Pydantic serialization using Field(exclude=True)
- Apply custom client guard to _live_api_client for consistency
- Add client parameter to ApigeeLlm.__init__ and forward to super()
@brucearctor
Copy link
Copy Markdown
Author

I think got these comments addressed. While I hate using Any type, to address your comments/suggestions, I failed to find a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models [Component] Issues related to model support request clarification [Status] The maintainer need clarification or more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants