🔴 Required Information
Describe the Bug:
When developing agent by LiteLlm, the adk web or adk api_server command raise an exception due to LiteLlm having a client field in type of LiteLLMClient that can't be deserialized to be part of FastAPI's response.
Steps to Reproduce:
- Install adk
- Develop an agent by
LiteLlm (see minimal reproducible code at the end)
- Run
$ adk web --port 8000
- Open
http://127.0.0.1:8000
- Error and stacktrace:
INFO: 127.0.0.1:57588 - "GET /dev/apps/my_agent/build_graph HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
<... skipped many lines>
pydantic_core._pydantic_core.PydanticSerializationError: Unable to serialize unknown type: <class 'google.adk.models.lite_llm.LiteLLMClient'>
Expected Behavior:
No 500 error for the HTTP request.
No error message in adk web or adk api_server stdout/stderr.
Observed Behavior:
500 error in HTTP request.
Error message showed as in above.
Environment Details:
- ADK Library Version (pip show google-adk): Version: 2.2.0
- Desktop OS: macOS
- Python Version (python -V): 3.14.4
Model Information:
- Are you using LiteLLM: Yes
- Which model is being used: google/gemma-4-26B-A4B-it
🟡 Optional Information
Additional Context:
Root cause:
LiteLlm.llm_client is a declared Pydantic field but its class LiteLLMClient has no JSON serializer. Any JSON serialization of a LiteLlm instance raises the error, e.g., when using FastAPI.
By contrast, Gemini exposes its api_client as a @cached_property, not a field, so it is never part of the serialized output.
A fix is obvious and trivial.
Minimal Reproduction Code:
model = LiteLlm(
model="...",
api_base="...",
)
root_agent = Agent(
model=model,
name='root_agent',
description='A helpful assistant for user questions.',
instruction='Answer user questions to the best of your knowledge',
)
How often has this issue occurred?:
🔴 Required Information
Describe the Bug:
When developing agent by
LiteLlm, theadk weboradk api_servercommand raise an exception due toLiteLlmhaving a client field in type ofLiteLLMClientthat can't be deserialized to be part of FastAPI's response.Steps to Reproduce:
LiteLlm(see minimal reproducible code at the end)$ adk web --port 8000http://127.0.0.1:8000Expected Behavior:
No 500 error for the HTTP request.
No error message in
adk weboradk api_serverstdout/stderr.Observed Behavior:
500 error in HTTP request.
Error message showed as in above.
Environment Details:
Model Information:
🟡 Optional Information
Additional Context:
Root cause:
LiteLlm.llm_clientis a declared Pydantic field but its classLiteLLMClienthas no JSON serializer. Any JSON serialization of aLiteLlminstance raises the error, e.g., when using FastAPI.By contrast,
Geminiexposes itsapi_clientas a@cached_property, not a field, so it is never part of the serialized output.A fix is obvious and trivial.
Minimal Reproduction Code:
How often has this issue occurred?: