Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(fireworks_ai): keep reasoning_content on replayed assistant messages (#40682)

devin-ai-integration[bot]7057b2f6c47b
diff --git a/litellm/llms/fireworks_ai/chat/transformation.py b/litellm/llms/fireworks_ai/chat/transformation.py
index 26ad9a02a79..b4e1856f499 100644
--- a/litellm/llms/fireworks_ai/chat/transformation.py
+++ b/litellm/llms/fireworks_ai/chat/transformation.py
@@ -511,7 +511,6 @@ class FireworksAIConfig(FireworksAIMixin, OpenAIGPTConfig):
m = cast(dict, message)
m.pop("provider_specific_fields", None)
m.pop("thinking_blocks", None)
- m.pop("reasoning_content", None)
return messages
diff --git a/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py b/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py
index d4ef4282b27..8479397efa7 100644
--- a/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py
+++ b/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py
@@ -501,8 +501,8 @@ def test_unmapped_model_fallback_function_calling():
assert info["supports_function_calling"] is True
-def test_transform_messages_helper_strips_thinking_blocks():
- """thinking_blocks must not be forwarded to Fireworks chat completions."""
+def test_transform_messages_helper_strips_thinking_blocks_but_keeps_reasoning_content():
+ """Fireworks rejects thinking_blocks but requires reasoning_content to be replayed for reasoning_history."""
config = FireworksAIConfig()
messages = [
{"role": "user", "content": "Translate a poem."},
@@ -519,7 +519,7 @@ def test_transform_messages_helper_strips_thinking_blocks():
messages, model="accounts/fireworks/models/glm-5p1", litellm_params={}
)
assert "thinking_blocks" not in out[1]
- assert "reasoning_content" not in out[1]
+ assert out[1]["reasoning_content"] == "internal"
assert out[1]["content"] == "I can help."