Describe the Bug:
The dev UI's agent-graph panel calls GET /dev/apps/{app}/build_graph, which returns 500 for any agent whose model is a LiteLlm instance. serialize_agent calls model_dump() on the model field, which embeds the live LiteLLMClient (LiteLlm.llm_client) — a non-JSON-serializable object — so FastAPI's response serialization raises PydanticSerializationError. Affects every LiteLLM-backed agent.
Steps to Reproduce:
- Install
google-adk==2.1.0.
- Minimal, framework-only reproduction:
import json
from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
from google.adk.cli.utils.graph_serialization import serialize_agent
agent = LlmAgent(name="repro", model=LiteLlm(model="ollama_chat/llama3"))
json.dumps(serialize_agent(agent))
# TypeError: Object of type LiteLLMClient is not JSON serializable
- End to end: run
adk web with a LiteLlm agent, open the agent in the UI; the graph panel fires GET /dev/apps/{app}/build_graph -> 500.
Expected Behavior:
build_graph returns a JSON graph of the agent; the model field is summarized (e.g. model name/string) rather than dumping the runtime client.
Observed Behavior:
500 Internal Server Error. Stack trace tail:
File ".../fastapi/_compat/v2.py", line 231, in serialize_json
return self._type_adapter.dump_json(...)
File ".../pydantic/type_adapter.py", line 677, in dump_json
return self.serializer.to_json(...)
pydantic_core._pydantic_core.PydanticSerializationError: Unable to serialize unknown type: <class 'google.adk.models.lite_llm.LiteLLMClient'>
Root cause: cli/utils/graph_serialization.py serialize_agent -> the generic else branch does value.model_dump() on the model field; LiteLlm.model_dump() includes llm_client: LiteLLMClient. The /dev/apps/{app}/build_graph route returns this raw (-> Any, no response model), so FastAPI then can't JSON-encode it. (Note: the route is already marked # TODO: remove this endpoint once build_graph_image is completed; build_graph_image returns 200.)
Environment Details:
- ADK Library Version (pip show google-adk): 2.1.0
- Desktop OS: macOS 26.5 (arm64)
- Python Version (python -V): 3.11.15
Model Information:
- Are you using LiteLLM: Yes (litellm 1.86.2)
- Which model is being used: ollama_chat/* via LiteLlm (e.g. ollama_chat/gemma4)
Describe the Bug:
The dev UI's agent-graph panel calls
GET /dev/apps/{app}/build_graph, which returns 500 for any agent whosemodelis aLiteLlminstance.serialize_agentcallsmodel_dump()on themodelfield, which embeds the liveLiteLLMClient(LiteLlm.llm_client) — a non-JSON-serializable object — so FastAPI's response serialization raisesPydanticSerializationError. Affects every LiteLLM-backed agent.Steps to Reproduce:
google-adk==2.1.0.adk webwith a LiteLlm agent, open the agent in the UI; the graph panel firesGET /dev/apps/{app}/build_graph-> 500.Expected Behavior:
build_graphreturns a JSON graph of the agent; themodelfield is summarized (e.g. model name/string) rather than dumping the runtime client.Observed Behavior:
500 Internal Server Error. Stack trace tail:
Root cause:
cli/utils/graph_serialization.pyserialize_agent-> the genericelsebranch doesvalue.model_dump()on themodelfield;LiteLlm.model_dump()includesllm_client: LiteLLMClient. The/dev/apps/{app}/build_graphroute returns this raw (-> Any, no response model), so FastAPI then can't JSON-encode it. (Note: the route is already marked# TODO: remove this endpoint once build_graph_image is completed;build_graph_imagereturns 200.)Environment Details:
Model Information: