LiteLLM agent BadRequestError
When I try to use the liteLLM agent with the providers it supports, the same error occurs every time.
raise BadRequestError(
litellm.exceptions.BadRequestError: litellm.BadRequestError: OpenAIException - The parameter `messages.content` specified in the request are not valid: expected a string, but got `[{"type":"text","text":"\n\n"}]` instead. Request id: 021744262261109ca8dc5cdfbc809995ade91978cdf2129fff4e5
Thanks for reporting! We'll take a look.
In the meanwhile, could you share more information about your setup for us to repro? E.g. agent definition (minimal just enough to repro), python version, os, etc.
Environment:
- OSX 14.5 (silicon)
- Python 3.12.9
Agent Definition:
from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
# ...
root_agent = LlmAgent(
model=LiteLlm(model="volcengine/deepseek-r1-250120"),
name="volcengine_agent",
description=(
"Agent to answer questions about the time and weather in a city."
),
instruction=(
"I can answer your questions about the time and weather in a city."
),
tools=[get_weather, get_current_time], # tools from adk examples
)
{
"role": "assistant",
"content": [],
"tool_calls": [
{
"function": {
"arguments": "{\"command\": \"ls /data01/workspace\"}",
"name": "run_linux_cmd"
},
"id": "call_0_28089ac9-2057-45ed-b15a-4391a52a4339",
"type": "function"
}
]
}
Since DeepSeek-R1 is not a multimodal model, it only supports content-type as string. Therefore, when the request contains content as an array, a JSON parse error will be prompted.
https://github.com/google/adk-python/blob/577222509c0f7ff7bd1fa4317eb20fd871a37daa/src/google/adk/models/lite_llm.py#L186
Maybe it's better to return "" for _get_content if the array length is 0.
return content_objects if len(content_objects) > 1 else ""
{ "role": "assistant", "content": [], "tool_calls": [ { "function": { "arguments": "{"command": "ls /data01/workspace"}", "name": "run_linux_cmd" }, "id": "call_0_28089ac9-2057-45ed-b15a-4391a52a4339", "type": "function" } ] } Since DeepSeek-R1 is not a multimodal model, it only supports content-type as string. Therefore, when the request contains content as an array, a JSON parse error will be prompted.
adk-python/src/google/adk/models/lite_llm.py
Line 186 in 5772225
def _get_content( Maybe it's better to return "" for
_get_contentif the array length is 0.
return content_objects if len(content_objects) > 1 else ""