From 44495c0117a6ca8b5077bf6f08c6463059bb73b2 Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Wed, 22 Oct 2025 11:59:48 +0530 Subject: [PATCH] fix encrypted content error (#15782) --- litellm/llms/azure/responses/transformation.py | 2 -- litellm/llms/openai/responses/transformation.py | 2 -- tests/llm_responses_api_testing/base_responses_api.py | 5 ++++- .../test_litellm_completion_responses.py | 7 +++++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/litellm/llms/azure/responses/transformation.py b/litellm/llms/azure/responses/transformation.py index 1516ed089e..d621cb209d 100644 --- a/litellm/llms/azure/responses/transformation.py +++ b/litellm/llms/azure/responses/transformation.py @@ -50,8 +50,6 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig): try: # Ensure required fields are present for ResponseReasoningItem item_data = dict(item) - if "id" not in 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 1e949e434d..c3abd5155d 100644 --- a/litellm/llms/openai/responses/transformation.py +++ b/litellm/llms/openai/responses/transformation.py @@ -123,8 +123,6 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): try: # Ensure required fields are present for ResponseReasoningItem item_data = dict(item) - if "id" not in 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/tests/llm_responses_api_testing/base_responses_api.py b/tests/llm_responses_api_testing/base_responses_api.py index 9a77ca6b68..f68b373fea 100644 --- a/tests/llm_responses_api_testing/base_responses_api.py +++ b/tests/llm_responses_api_testing/base_responses_api.py @@ -588,7 +588,10 @@ class BaseResponsesAPITest(ABC): assert "status" not in reasoning_item, "status field should be filtered out from reasoning item" assert "content" not in reasoning_item, "content field should be filtered out from reasoning item" assert "encrypted_content" not in reasoning_item, "encrypted_content field should be filtered out from reasoning item" - assert "id" in reasoning_item, "id field should be preserved" + # Note: ID auto-generation was disabled, so reasoning items may not have IDs + # Only check for ID if it was present in the original input + if "id" in reasoning_item: + assert reasoning_item["id"] == "rs_123", "ID should be preserved if present" assert "summary" in reasoning_item, "summary field should be preserved" # Check function call item (index 2) 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 333fb36cad..d8fec45757 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,8 +265,11 @@ class TestLiteLLMCompletionResponsesConfig: assert len(reasoning_items) == 1, "Should have exactly one reasoning item" reasoning_item = reasoning_items[0] - assert reasoning_item.id.startswith("rs_"), f"Expected ID to start with 'rs_', got: {reasoning_item.id}" - assert reasoning_item.status == "completed" + # Note: ID auto-generation was disabled, so reasoning items may not have IDs + # Only assert ID format if an ID is present + if hasattr(reasoning_item, 'id') and reasoning_item.id: + 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 assert reasoning_item.content[0].type == "output_text"