Skip to content

feat: add Responses websocket model and stream_ws example#2530

Merged
seratch merged 1 commit intomainfrom
feat/responses-ws-model
Feb 23, 2026
Merged

feat: add Responses websocket model and stream_ws example#2530
seratch merged 1 commit intomainfrom
feat/responses-ws-model

Conversation

@seratch
Copy link
Member

@seratch seratch commented Feb 23, 2026

This pull request adds Responses WebSocket model support and a new examples/basic/stream_ws.py example to the Python Agents SDK.

The change introduces a responses_websocket_session implementation, extends model/provider/config plumbing to support a websocket-backed Responses path, and updates streamed runner behavior so the new model can run through existing agent interfaces. It also adds test coverage for config/model mapping, streamed execution, tracing, and websocket session behavior.

This is a user-facing runtime feature addition with public configuration/model-selection impact, so reviewers should pay attention to backward compatibility and streamed/non-streamed behavior alignment. Related docs reference: WebSocket mode guide.

import asyncio
from agents import Agent, responses_websocket_session

async def main() -> None:
    agent = Agent(
        name="Assistant",
        instructions="You are a helpful assistant.",
        model="gpt-5.2-codex",
    )
    async with responses_websocket_session() as session:
        result = session.run_streamed(agent, "Say hello in one sentence.")
        async for event in result.stream_events():
            if event.type == "raw_response_event" and event.data.type == "response.output_text.delta":
                print(event.data.delta, end="", flush=True)

        print()  # newline after streamed text

asyncio.run(main())

@seratch seratch added this to the 0.9.x milestone Feb 23, 2026
@seratch seratch merged commit c4a2fcb into main Feb 23, 2026
9 checks passed
@seratch seratch deleted the feat/responses-ws-model branch February 23, 2026 22:08
@seratch seratch modified the milestones: 0.9.x, 0.10.x Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant