Skip to content

Commit 2525ea4

Browse files
fix(openai): bound realtime voice websocket payload at 16 MiB (#99450)
* fix(openai): bound realtime voice websocket payload at 16 MiB * test(openai): cover realtime voice payload cap --------- Co-authored-by: Peter Steinberger <[email protected]>
1 parent aaf5ab9 commit 2525ea4

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

extensions/openai/realtime-voice-provider.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,16 @@ describe("buildOpenAIRealtimeVoiceProvider", () => {
333333
bridge.close();
334334

335335
const socket = FakeWebSocket.instances[0];
336-
const options = socket?.args[1] as { headers?: Record<string, string> } | undefined;
336+
const options = socket?.args[1] as
337+
| { headers?: Record<string, string>; maxPayload?: number }
338+
| undefined;
337339
expectRecordFields(options?.headers, "websocket headers", {
338340
originator: "openclaw",
339341
version: "2026.3.22",
340342
"User-Agent": "openclaw/2026.3.22",
341343
});
342344
expect(options?.headers).not.toHaveProperty("OpenAI-Beta");
345+
expect(options?.maxPayload).toBe(16 * 1024 * 1024);
343346
});
344347

345348
it("requires a Platform API key for native realtime websocket bridges", async () => {

extensions/openai/realtime-voice-provider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const OPENAI_REALTIME_ACTIVE_RESPONSE_ERROR_PREFIX =
9393
const OPENAI_REALTIME_NO_ACTIVE_RESPONSE_CANCEL_ERROR =
9494
"Cancellation failed: no active response found";
9595
const OPENAI_REALTIME_MAX_SESSION_DURATION_FRAGMENT = "maximum duration";
96+
const OPENAI_VOICE_WS_MAX_PAYLOAD_BYTES = 16 * 1024 * 1024;
9697
const OPENAI_REALTIME_DEFAULT_MIN_BARGE_IN_AUDIO_END_MS = 250;
9798
// Realtime validates this character set but accepts names beyond the 64-character
9899
// cap used by other OpenAI tool surfaces.
@@ -616,6 +617,7 @@ class OpenAIRealtimeVoiceBridge implements RealtimeVoiceBridge {
616617
const proxyAgent = createDebugProxyWebSocketAgent(debugProxy);
617618
const ws = new WebSocket(connection.url, {
618619
headers: connection.headers,
620+
maxPayload: OPENAI_VOICE_WS_MAX_PAYLOAD_BYTES,
619621
...(proxyAgent ? { agent: proxyAgent } : {}),
620622
});
621623
this.ws = ws;

0 commit comments

Comments
 (0)