fix(models): exclude LiteLlm's llm_client from field serialization#6165
Open
claud42 wants to merge 1 commit into
Open
fix(models): exclude LiteLlm's llm_client from field serialization#6165claud42 wants to merge 1 commit into
claud42 wants to merge 1 commit into
Conversation
Fixes google#6164 LiteLlm stores its client as a Pydantic field which has no JSON serializer. Any JSON dump of a LiteLlm therefore raises `PydanticSerializationError`, which surfaces as a 500 in `adk web` / `adk api_server` whenever a LiteLlm reaches a response payload. Ether provider (Gemini, Anthropic, Apigee) keeps its client off the model as a @cached_property, so it is never serialized. LiteLlm intentionally exposes llm_client as an injectable field for testing, so rather than convert it, mark it `exclude=True` — the client is dropped from serialization while remaining constructible and unchanged at runtime. Testing: - pytest tests/unittests/models/test_litellm.py (all pass)
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Collaborator
|
@claud42 can you sign the CLA? |
Author
|
@wuliang229 I submitted the CLA immediately after created this PR. Not sure how long it would take to be approved or synchronized here though. |
Author
|
@wuliang229 The CLA check has passed. |
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.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
LiteLlm stores its client as a Pydantic field which has no JSON serializer. Any JSON dump of a LiteLlm therefore raises
PydanticSerializationError, which surfaces as a 500 inadk web/adk api_serverwhenever a LiteLlm reaches a response payload.Solution:
Ether provider (Gemini, Anthropic, Apigee) keeps its client off the model as a
@cached_property, so it is never serialized. LiteLlm intentionally exposes llm_client as an injectable field for testing, so rather than convert it, mark itexclude=True— the client is dropped from serialization while remaining constructible and unchanged at runtime.Testing Plan
Unit Tests:
pytest tests/unittests/models/test_litellm.py (all pass)
Manual End-to-End (E2E) Tests:
Code and commands to re-produce the issue was provided in original issue ticket.
The problem resolved end to end with this fix.
Checklist