Skip to content

Commit 416cca9

Browse files
test(openai-agents): Set streaming header when library uses with_streaming_response()
1 parent a920f4e commit 416cca9

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/integrations/openai_agents/test_openai_agents.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,15 @@ async def test_hosted_mcp_tool_propagation_header_streamed(
12491249
"/responses",
12501250
)
12511251

1252+
# openai-agents calls with_streaming_response() if available starting with
1253+
# https://github.com/openai/openai-agents-python/commit/159beb56130f7d85192acfd593c9168757984dc0.
1254+
# When using with_streaming_response() the header set below changes the response type:
1255+
# https://github.com/openai/openai-python/blob/656e3cab4a18262a49b961d41293367e45ee71b9/src/openai/_response.py#L67.
1256+
if parse_version(OPENAI_AGENTS_VERSION) >= (0, 10, 3) and hasattr(
1257+
agent_with_tool.model._client.responses, "with_streaming_response"
1258+
):
1259+
request.headers["X-Stainless-Raw-Response"] = "stream"
1260+
12521261
response = httpx.Response(
12531262
200,
12541263
request=request,
@@ -2833,6 +2842,15 @@ async def test_streaming_ttft_on_chat_span(sentry_init, test_agent, async_iterat
28332842
"/responses",
28342843
)
28352844

2845+
# openai-agents calls with_streaming_response() if available starting with
2846+
# https://github.com/openai/openai-agents-python/commit/159beb56130f7d85192acfd593c9168757984dc0.
2847+
# When using with_streaming_response() the header set below changes the response type:
2848+
# https://github.com/openai/openai-python/blob/656e3cab4a18262a49b961d41293367e45ee71b9/src/openai/_response.py#L67.
2849+
if parse_version(OPENAI_AGENTS_VERSION) >= (0, 10, 3) and hasattr(
2850+
agent_with_tool.model._client.responses, "with_streaming_response"
2851+
):
2852+
request.headers["X-Stainless-Raw-Response"] = "stream"
2853+
28362854
response = httpx.Response(
28372855
200,
28382856
request=request,

0 commit comments

Comments
 (0)