Skip to content

Commit eca3a7c

Browse files
committed
fix(openai): propagate PCM sideband audio format
The browser sideband negotiated PCM16, but its bridge defaulted to G.711 for duration accounting. Propagate the negotiated format so truncation uses the actual PCM duration and closes ClawSweeper's in-scope finding.
1 parent 8e8a9e1 commit eca3a7c

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎extensions/openai/realtime-voice-bridge-connection.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,28 @@ describe("OpenAI realtime voice bridge connection", () => {
194194
type: "session.created",
195195
detail: "tools=1 toolChoice=auto",
196196
});
197+
198+
bridge.setMediaTimestamp(1_000);
199+
emitServerEvent(socket, {
200+
type: "response.output_audio.delta",
201+
item_id: "item_pcm",
202+
delta: Buffer.alloc(3_700 * 48).toString("base64"),
203+
});
204+
bridge.setMediaTimestamp(4_760);
205+
bridge.handleBargeIn?.({ audioPlaybackActive: true });
206+
207+
expect(parseSent(socket).slice(-2)).toEqual([
208+
{
209+
type: "response.cancel",
210+
event_id: expect.stringMatching(/^openclaw-response-cancel-/),
211+
},
212+
{
213+
type: "conversation.item.truncate",
214+
item_id: "item_pcm",
215+
content_index: 0,
216+
audio_end_ms: 3_700,
217+
},
218+
]);
197219
bridge.close();
198220
expect(fetchWithSsrFGuardMock).not.toHaveBeenCalled();
199221
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ async function createOpenAIRealtimeBrowserSession(
219219
providerConfig: req.providerConfig,
220220
apiKey,
221221
callId,
222+
audioFormat: REALTIME_VOICE_AUDIO_FORMAT_PCM16_24KHZ,
222223
gaSessionPolicy: sessionConfig,
223224
model,
224225
voice,

0 commit comments

Comments
 (0)