From 9a4af37646764a282d9e900a90f89b82ce5e513f Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 4 Mar 2026 11:22:57 +0100 Subject: [PATCH] test(openai-agents): Remove test for unreachable state --- .../openai_agents/test_openai_agents.py | 69 ------------------- 1 file changed, 69 deletions(-) diff --git a/tests/integrations/openai_agents/test_openai_agents.py b/tests/integrations/openai_agents/test_openai_agents.py index 491223e804..1c036bb669 100644 --- a/tests/integrations/openai_agents/test_openai_agents.py +++ b/tests/integrations/openai_agents/test_openai_agents.py @@ -2507,75 +2507,6 @@ def calculator(a: int, b: int) -> int: assert invoke_agent_span["data"]["gen_ai.usage.output_tokens.reasoning"] == 3 -@pytest.mark.asyncio -async def test_response_model_not_set_when_unavailable( - sentry_init, capture_events, test_agent -): - """ - Test that response model is not set if the API response doesn't have a model field. - The request model should still be set correctly. - """ - - with patch.dict(os.environ, {"OPENAI_API_KEY": "test-key"}): - with patch( - "agents.models.openai_responses.OpenAIResponsesModel._fetch_response" - ) as mock_fetch_response: - # Create a mock response without a model field - mock_response = MagicMock() - mock_response.model = None # No model in response - mock_response.id = "resp_123" - mock_response.output = [ - ResponseOutputMessage( - id="msg_123", - type="message", - status="completed", - content=[ - ResponseOutputText( - text="Response without model field", - type="output_text", - annotations=[], - ) - ], - role="assistant", - ) - ] - mock_response.usage = MagicMock() - mock_response.usage.input_tokens = 10 - mock_response.usage.output_tokens = 20 - mock_response.usage.total_tokens = 30 - mock_response.usage.input_tokens_details = InputTokensDetails( - cached_tokens=0 - ) - mock_response.usage.output_tokens_details = OutputTokensDetails( - reasoning_tokens=0 - ) - - mock_fetch_response.return_value = mock_response - - sentry_init( - integrations=[OpenAIAgentsIntegration()], - traces_sample_rate=1.0, - ) - - events = capture_events() - - result = await agents.Runner.run( - test_agent, "Test input", run_config=test_run_config - ) - - assert result is not None - - (transaction,) = events - spans = transaction["spans"] - _, ai_client_span = spans - - # Response model should NOT be set when API doesn't return it - assert "gen_ai.response.model" not in ai_client_span["data"] - # But request model should still be set - assert "gen_ai.request.model" in ai_client_span["data"] - assert ai_client_span["data"]["gen_ai.request.model"] == "gpt-4" - - @pytest.mark.asyncio async def test_invoke_agent_span_includes_response_model( sentry_init, capture_events, test_agent