Skip to content

Commit e9a3e36

Browse files
authored
docs: updates for #3080 (#3081)
1 parent ceb238f commit e9a3e36

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

docs/models/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ provider = OpenAIProvider(
123123
use_responses_websocket=True,
124124
# Optional; if omitted, OPENAI_WEBSOCKET_BASE_URL is used when set.
125125
websocket_base_url="wss://your-proxy.example/v1",
126+
# Optional low-level websocket keepalive settings.
127+
responses_websocket_options={"ping_interval": 20.0, "ping_timeout": 60.0},
126128
)
127129

128130
agent = Agent(name="Assistant")
@@ -203,6 +205,7 @@ If you use a custom OpenAI-compatible endpoint or proxy, websocket transport als
203205
- This is the Responses API over websocket transport, not the [Realtime API](../realtime/guide.md). It does not apply to Chat Completions or non-OpenAI providers unless they support the Responses websocket `/responses` endpoint.
204206
- Install the `websockets` package if it is not already available in your environment.
205207
- You can use [`Runner.run_streamed()`][agents.run.Runner.run_streamed] directly after enabling websocket transport. For multi-turn workflows where you want to reuse the same websocket connection across turns (and nested agent-as-tool calls), the [`responses_websocket_session()`][agents.responses_websocket_session] helper is recommended. See the [Running agents](../running_agents.md) guide and [`examples/basic/stream_ws.py`](https://github.com/openai/openai-agents-python/tree/main/examples/basic/stream_ws.py).
208+
- For long reasoning turns or networks with latency spikes, customize websocket keepalive behavior with `responses_websocket_options`. Increase `ping_timeout` to tolerate delayed pong frames, or set `ping_timeout=None` to disable heartbeat timeouts while keeping pings enabled. Prefer HTTP/SSE transport when reliability is more important than websocket latency.
206209

207210
## Non-OpenAI models
208211

docs/running_agents.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ from agents import Agent, responses_websocket_session
9696
async def main():
9797
agent = Agent(name="Assistant", instructions="Be concise.")
9898

99-
async with responses_websocket_session() as ws:
99+
async with responses_websocket_session(
100+
responses_websocket_options={"ping_interval": 20.0, "ping_timeout": 60.0},
101+
) as ws:
100102
first = ws.run_streamed(agent, "Say hello in one short sentence.")
101103
async for _event in first.stream_events():
102104
pass
@@ -115,6 +117,8 @@ asyncio.run(main())
115117

116118
Finish consuming streamed results before the context exits. Exiting the context while a websocket request is still in flight may force-close the shared connection.
117119

120+
If long reasoning turns hit websocket keepalive timeouts, increase `ping_timeout` or set `ping_timeout=None` to disable heartbeat timeouts. Use HTTP/SSE transport for runs where reliability matters more than websocket latency.
121+
118122
### Run config
119123

120124
The `run_config` parameter lets you configure some global settings for the agent run:

0 commit comments

Comments
 (0)