litellm/tests/unit/llms/openai/chat
Kerry Lu 9dc4449b7f
fix(openai): give a reasoning-only assistant message empty content (#55539)
* fix(openai): give a reasoning-only assistant message empty content

A Responses API request replayed through the chat completions bridge turns a
reasoning item with no following answer into an assistant message that carries
only reasoning. The None-field cleanup then drops its content key, and strict
OpenAI-compatible servers such as llama.cpp answer 400 with "Assistant message
must contain either 'content' or 'tool_calls'!". The same happens when a chat
completions client replays a reasoning-only assistant turn.

The OpenAI chat request builder now sends content "" on an assistant message
that has reasoning but no content, tool calls or function call. The bridge
keeps content None, so the reasoning merge pass and the Anthropic, Gemini and
Bedrock converters see the same messages as before.

Fixes #54504

* fix(hosted_vllm): give an assistant message with only signed thinking blocks empty content

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(openai): cover a legacy function call and an assistant turn with no content and no reasoning

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-12-02 13:17:41 -08:00
..
guardrail_translation fix(guardrails)!: close gaps in bedrock tool call and tool description scans (#54169) 2026-11-25 06:56:15 +00:00
__init__.py
test_openai_gpt_transformation.py fix(openai): give a reasoning-only assistant message empty content (#55539) 2026-12-02 13:17:41 -08:00