@@ -518,6 +518,7 @@ def test_response_content_creation_with_reasoning() -> None:
518518 mock_reasoning_item .type = "reasoning"
519519 mock_reasoning_item .content = [mock_reasoning_content ]
520520 mock_reasoning_item .summary = [Summary (text = "Summary" , type = "summary_text" )]
521+ mock_reasoning_item .encrypted_content = None
521522
522523 mock_response .output = [mock_reasoning_item ]
523524
@@ -568,6 +569,11 @@ def test_response_reasoning_preserves_encrypted_content_with_summary() -> None:
568569 assert first_reasoning .additional_properties .get ("encrypted_content" ) == "gAAAA_encrypted_payload"
569570 assert first_reasoning .additional_properties .get ("summary" ) is not None
570571
572+ # The summary branch Content should also carry encrypted_content
573+ assert len (reasoning_contents ) >= 2
574+ assert reasoning_contents [1 ].additional_properties is not None
575+ assert reasoning_contents [1 ].additional_properties .get ("encrypted_content" ) == "gAAAA_encrypted_payload"
576+
571577
572578def test_response_reasoning_preserves_encrypted_content_summary_only () -> None :
573579 """encrypted_content must survive when only summary (no content) is present.
@@ -605,6 +611,40 @@ def test_response_reasoning_preserves_encrypted_content_summary_only() -> None:
605611 assert summary_reasoning .additional_properties .get ("encrypted_content" ) == "gAAAA_encrypted_payload_2"
606612
607613
614+ def test_response_reasoning_no_encrypted_content () -> None :
615+ """When encrypted_content is None/missing, additional_properties should not contain it."""
616+ client = OpenAIResponsesClient (model_id = "test-model" , api_key = "test-key" )
617+
618+ mock_response = MagicMock ()
619+ mock_response .output_parsed = None
620+ mock_response .metadata = {}
621+ mock_response .usage = None
622+ mock_response .id = "test-id"
623+ mock_response .model = "test-model"
624+ mock_response .created_at = 1000000000
625+
626+ mock_reasoning_content = MagicMock ()
627+ mock_reasoning_content .text = "Reasoning step"
628+
629+ mock_reasoning_item = MagicMock ()
630+ mock_reasoning_item .type = "reasoning"
631+ mock_reasoning_item .id = "rs_no_enc"
632+ mock_reasoning_item .content = [mock_reasoning_content ]
633+ mock_reasoning_item .summary = [Summary (text = "Summary text" , type = "summary_text" )]
634+ mock_reasoning_item .encrypted_content = None
635+
636+ mock_response .output = [mock_reasoning_item ]
637+
638+ response = client ._parse_response_from_openai (mock_response , options = {}) # type: ignore
639+
640+ reasoning_contents = [c for c in response .messages [0 ].contents if c .type == "text_reasoning" ]
641+ assert len (reasoning_contents ) >= 1
642+ for rc in reasoning_contents :
643+ # additional_properties should either be None or not contain encrypted_content
644+ if rc .additional_properties is not None :
645+ assert "encrypted_content" not in rc .additional_properties
646+
647+
608648def test_response_content_keeps_reasoning_and_function_calls_in_one_message () -> None :
609649 """Reasoning + function calls should parse into one assistant message."""
610650 client = OpenAIResponsesClient (model_id = "test-model" , api_key = "test-key" )
@@ -625,6 +665,7 @@ def test_response_content_keeps_reasoning_and_function_calls_in_one_message() ->
625665 mock_reasoning_item .id = "rs_123"
626666 mock_reasoning_item .content = [mock_reasoning_content ]
627667 mock_reasoning_item .summary = []
668+ mock_reasoning_item .encrypted_content = None
628669
629670 mock_function_call_item_1 = MagicMock ()
630671 mock_function_call_item_1 .type = "function_call"
0 commit comments