|
3 | 3 | from typing import Any
|
4 | 4 |
|
5 | 5 | import pytest
|
| 6 | +from openai import NOT_GIVEN |
6 | 7 | from openai.types.responses import ResponseCompletedEvent
|
7 | 8 |
|
8 | 9 | from agents import ModelSettings, ModelTracing, __version__
|
@@ -63,3 +64,35 @@ def __init__(self):
|
63 | 64 |
|
64 | 65 | assert "extra_headers" in called_kwargs
|
65 | 66 | assert called_kwargs["extra_headers"]["User-Agent"] == expected_ua
|
| 67 | + |
| 68 | + |
| 69 | +@pytest.mark.allow_call_model_methods |
| 70 | +@pytest.mark.asyncio |
| 71 | +async def test_prompt_id_omits_model_parameter(): |
| 72 | + called_kwargs: dict[str, Any] = {} |
| 73 | + |
| 74 | + class DummyResponses: |
| 75 | + async def create(self, **kwargs): |
| 76 | + nonlocal called_kwargs |
| 77 | + called_kwargs = kwargs |
| 78 | + return get_response_obj([]) |
| 79 | + |
| 80 | + class DummyResponsesClient: |
| 81 | + def __init__(self): |
| 82 | + self.responses = DummyResponses() |
| 83 | + |
| 84 | + model = OpenAIResponsesModel(model="gpt-4", openai_client=DummyResponsesClient()) # type: ignore[arg-type] |
| 85 | + |
| 86 | + await model.get_response( |
| 87 | + system_instructions=None, |
| 88 | + input="hi", |
| 89 | + model_settings=ModelSettings(), |
| 90 | + tools=[], |
| 91 | + output_schema=None, |
| 92 | + handoffs=[], |
| 93 | + tracing=ModelTracing.DISABLED, |
| 94 | + prompt={"id": "pmpt_123"}, |
| 95 | + ) |
| 96 | + |
| 97 | + assert called_kwargs["prompt"] == {"id": "pmpt_123"} |
| 98 | + assert called_kwargs["model"] is NOT_GIVEN |
0 commit comments