Skip to content

'final_content' can be None sometimes, and openai API cannot accept none value #1801

@WangRRRui

Description

@WangRRRui

Describe the bug
I receive OpenAi 500 internal error when my agent attempt to call llm after a tool call. I find that this field can be None(and it will be passed to the 'content' field when calling LLM). My LLM is a private deployed LLM with openAI api style and i tried a list of LLMs, all of them cannot accept None value.

This can be fixed if replacing this None value(google/adk/models/lite_llm.py line 202) to empty string.

Image

To Reproduce
Steps to reproduce the behavior:

  1. run agent after specific tool call
  2. call llm

Expected behavior
18:33:55 - LiteLLM:INFO: utils.py:3173 -
LiteLLM completion() model= us.anthropic.claude-sonnet-4-20250514-v1:0; provider = openai
2025-07-04 18:33:55,968 - INFO - utils.py:3173 -
LiteLLM completion() model= us.anthropic.claude-sonnet-4-20250514-v1:0; provider = openai
2025-07-04 18:33:56,382 - INFO - _client.py:1740 - HTTP Request: POST https://pre-openai-keys.alibaba-inc.com/v1/chat/completions "HTTP/1.1 500 Internal Server Error"
2025-07-04 18:33:56,382 - INFO - _base_client.py:1608 - Retrying request to /chat/completions in 0.497158 seconds
2025-07-04 18:33:57,206 - INFO - _client.py:1740 - HTTP Request: POST https://pre-openai-keys.alibaba-inc.com/v1/chat/completions "HTTP/1.1 500 Internal Server Error"
2025-07-04 18:33:57,207 - INFO - _base_client.py:1608 - Retrying request to /chat/completions in 0.763697 seconds
2025-07-04 18:33:58,237 - INFO - _client.py:1740 - HTTP Request: POST https://pre-openai-keys.alibaba-inc.com/v1/chat/completions "HTTP/1.1 500 Internal Server Error"

Model Information:
claude-sonnet-4-20250514-v1:0

Additional context
google/adk/models/lite_llm.py line 202

Metadata

Metadata

Assignees

Labels

models[Component] Issues related to model supportrequest clarification[Status] The maintainer need clarification or more information from the author

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions