Skip to content

Commit 9a4af37

Browse files
test(openai-agents): Remove test for unreachable state
1 parent 4f16a9e commit 9a4af37

File tree

1 file changed

+0
-69
lines changed

1 file changed

+0
-69
lines changed

tests/integrations/openai_agents/test_openai_agents.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,75 +2507,6 @@ def calculator(a: int, b: int) -> int:
25072507
assert invoke_agent_span["data"]["gen_ai.usage.output_tokens.reasoning"] == 3
25082508

25092509

2510-
@pytest.mark.asyncio
2511-
async def test_response_model_not_set_when_unavailable(
2512-
sentry_init, capture_events, test_agent
2513-
):
2514-
"""
2515-
Test that response model is not set if the API response doesn't have a model field.
2516-
The request model should still be set correctly.
2517-
"""
2518-
2519-
with patch.dict(os.environ, {"OPENAI_API_KEY": "test-key"}):
2520-
with patch(
2521-
"agents.models.openai_responses.OpenAIResponsesModel._fetch_response"
2522-
) as mock_fetch_response:
2523-
# Create a mock response without a model field
2524-
mock_response = MagicMock()
2525-
mock_response.model = None # No model in response
2526-
mock_response.id = "resp_123"
2527-
mock_response.output = [
2528-
ResponseOutputMessage(
2529-
id="msg_123",
2530-
type="message",
2531-
status="completed",
2532-
content=[
2533-
ResponseOutputText(
2534-
text="Response without model field",
2535-
type="output_text",
2536-
annotations=[],
2537-
)
2538-
],
2539-
role="assistant",
2540-
)
2541-
]
2542-
mock_response.usage = MagicMock()
2543-
mock_response.usage.input_tokens = 10
2544-
mock_response.usage.output_tokens = 20
2545-
mock_response.usage.total_tokens = 30
2546-
mock_response.usage.input_tokens_details = InputTokensDetails(
2547-
cached_tokens=0
2548-
)
2549-
mock_response.usage.output_tokens_details = OutputTokensDetails(
2550-
reasoning_tokens=0
2551-
)
2552-
2553-
mock_fetch_response.return_value = mock_response
2554-
2555-
sentry_init(
2556-
integrations=[OpenAIAgentsIntegration()],
2557-
traces_sample_rate=1.0,
2558-
)
2559-
2560-
events = capture_events()
2561-
2562-
result = await agents.Runner.run(
2563-
test_agent, "Test input", run_config=test_run_config
2564-
)
2565-
2566-
assert result is not None
2567-
2568-
(transaction,) = events
2569-
spans = transaction["spans"]
2570-
_, ai_client_span = spans
2571-
2572-
# Response model should NOT be set when API doesn't return it
2573-
assert "gen_ai.response.model" not in ai_client_span["data"]
2574-
# But request model should still be set
2575-
assert "gen_ai.request.model" in ai_client_span["data"]
2576-
assert ai_client_span["data"]["gen_ai.request.model"] == "gpt-4"
2577-
2578-
25792510
@pytest.mark.asyncio
25802511
async def test_invoke_agent_span_includes_response_model(
25812512
sentry_init, capture_events, test_agent

0 commit comments

Comments
 (0)