From 562beaba05e64ed341ecae767a5b14c9db49cb59 Mon Sep 17 00:00:00 2001 From: "Claud X." <1960626+claud42@users.noreply.github.com> Date: Thu, 18 Jun 2026 14:15:33 -0700 Subject: [PATCH] fix(models): exclude LiteLlm's llm_client from field serialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #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) --- src/google/adk/models/lite_llm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/adk/models/lite_llm.py b/src/google/adk/models/lite_llm.py index a33bce272b..bf59a1e418 100644 --- a/src/google/adk/models/lite_llm.py +++ b/src/google/adk/models/lite_llm.py @@ -2322,7 +2322,7 @@ class LiteLlm(BaseLlm): llm_client: The LLM client to use for the model. """ - llm_client: LiteLLMClient = Field(default_factory=LiteLLMClient) + llm_client: LiteLLMClient = Field(default_factory=LiteLLMClient, exclude=True) """The LLM client to use for the model.""" _additional_args: Dict[str, Any] = None