Skip to content

Commit cf886cd

Browse files
committed
refactor: default turnDetectionDisabled in the session signature
1 parent 6d36985 commit cf886cd

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

agents/src/voice/realtime_auto_disable_turn_detection.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ class FakeRealtimeSession extends RealtimeSession {
5959
readonly chatCtx = ChatContext.empty();
6060
readonly tools = ToolContext.empty();
6161

62-
constructor(model: RealtimeModel, options: RealtimeSessionOptions = {}) {
62+
constructor(
63+
model: RealtimeModel,
64+
{ turnDetectionDisabled = false }: RealtimeSessionOptions = {},
65+
) {
6366
super(model);
64-
this.turnDetectionDisabled = options.turnDetectionDisabled ?? false;
67+
this.turnDetectionDisabled = turnDetectionDisabled;
6568
}
6669

6770
async updateInstructions() {}

plugins/openai/src/realtime/realtime_model.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,10 @@ export class RealtimeSession extends llm.RealtimeSession {
492492
#task: Task<void>;
493493
#closed = false;
494494

495-
constructor(realtimeModel: RealtimeModel, options: llm.RealtimeSessionOptions = {}) {
495+
constructor(
496+
realtimeModel: RealtimeModel,
497+
{ turnDetectionDisabled = false }: llm.RealtimeSessionOptions = {},
498+
) {
496499
super(realtimeModel);
497500

498501
this.oaiRealtimeModel = realtimeModel;
@@ -503,7 +506,7 @@ export class RealtimeSession extends llm.RealtimeSession {
503506
// diff to always see "no change" and never send session.update.
504507
this._options = {
505508
...realtimeModel._options,
506-
turnDetection: options.turnDetectionDisabled ? null : realtimeModel._options.turnDetection,
509+
turnDetection: turnDetectionDisabled ? null : realtimeModel._options.turnDetection,
507510
};
508511

509512
this.#task = Task.from(({ signal }) => this.#mainTask(signal));

0 commit comments

Comments
 (0)