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 the reasoningresponse id (#15265)

Sameer Kankute73f96712f585
diff --git a/litellm/llms/azure/responses/transformation.py b/litellm/llms/azure/responses/transformation.py
index 9cd5de46be9..cf9f970995c 100644
--- a/litellm/llms/azure/responses/transformation.py
+++ b/litellm/llms/azure/responses/transformation.py
@@ -53,7 +53,7 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig):
# Ensure required fields are present for ResponseReasoningItem
item_data = dict(item)
if "id" not in item_data:
- item_data["id"] = f"reasoning_{hash(str(item_data))}"
+ item_data["id"] = f"rs_{hash(str(item_data))}"
if "summary" not in item_data:
item_data["summary"] = (
item_data.get("reasoning_content", "")[:100] + "..."
diff --git a/litellm/llms/openai/responses/transformation.py b/litellm/llms/openai/responses/transformation.py
index 0f67401b3d0..e5e89cd8bc6 100644
--- a/litellm/llms/openai/responses/transformation.py
+++ b/litellm/llms/openai/responses/transformation.py
@@ -124,7 +124,7 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
# Ensure required fields are present for ResponseReasoningItem
item_data = dict(item)
if "id" not in item_data:
- item_data["id"] = f"reasoning_{hash(str(item_data))}"
+ item_data["id"] = f"rs_{hash(str(item_data))}"
if "summary" not in item_data:
item_data["summary"] = (
item_data.get("reasoning_content", "")[:100] + "..."
diff --git a/litellm/responses/litellm_completion_transformation/streaming_iterator.py b/litellm/responses/litellm_completion_transformation/streaming_iterator.py
index 93abdee778f..20822b3628e 100644
--- a/litellm/responses/litellm_completion_transformation/streaming_iterator.py
+++ b/litellm/responses/litellm_completion_transformation/streaming_iterator.py
@@ -134,7 +134,7 @@ class LiteLLMCompletionStreamingIterator(ResponsesAPIStreamingIterator):
return ReasoningSummaryTextDeltaEvent(
type=ResponsesAPIStreamEvents.REASONING_SUMMARY_TEXT_DELTA,
- item_id=f"{chunk.id}_reasoning",
+ item_id=f"rs_{hash(str(reasoning_content))}",
output_index=0,
delta=reasoning_content,
)
diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.py
index a43e02a0f3e..9324ab0aa0c 100644
--- a/litellm/responses/litellm_completion_transformation/transformation.py
+++ b/litellm/responses/litellm_completion_transformation/transformation.py
@@ -708,7 +708,7 @@ class LiteLLMCompletionResponsesConfig:
return [
GenericResponseOutputItem(
type="reasoning",
- id=f"{chat_completion_response.id}_reasoning",
+ id=f"rs_{hash(str(message.reasoning_content))}",
status=choice.finish_reason,
role="assistant",
content=[
diff --git a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py
index 00fa0851a7b..9c8da2e60e0 100644
--- a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py
+++ b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py
@@ -265,7 +265,7 @@ class TestLiteLLMCompletionResponsesConfig:
assert len(reasoning_items) == 1, "Should have exactly one reasoning item"
reasoning_item = reasoning_items[0]
- assert reasoning_item.id == "test-response-id_reasoning"
+ assert reasoning_item.id.startswith("rs_"), f"Expected ID to start with 'rs_', got: {reasoning_item.id}"
assert reasoning_item.status == "stop"
assert reasoning_item.role == "assistant"
assert len(reasoning_item.content) == 1