Skip to content

Commit 7d24bf0

Browse files
committed
fix util migration tests
1 parent 8f53889 commit 7d24bf0

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

agents/src/voice/turn_config/utils.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('migrateLegacyOptions', () => {
3030
const result = migrateLegacyOptions(input);
3131

3232
expect(result.turnHandling!.turnDetection).toBe('vad');
33-
expect('turnDetection' in result).toBe(false);
33+
expect(result.turnDetection).toBe('vad');
3434
});
3535

3636
it('should set interruption.mode to false when allowInterruptions is false', () => {
@@ -42,7 +42,7 @@ describe('migrateLegacyOptions', () => {
4242
const result = migrateLegacyOptions(input);
4343

4444
expect(result.turnHandling!.interruption!.mode).toBe(false);
45-
expect('voiceOptions' in result).toBe(false);
45+
expect(result.voiceOptions?.allowInterruptions).toBe(false);
4646
});
4747

4848
it('should not set interruption.mode when allowInterruptions is true', () => {
@@ -133,9 +133,9 @@ describe('migrateLegacyOptions', () => {
133133
expect(result.turnHandling!.preemptiveGeneration).toBe(true);
134134
expect(result.turnHandling!.userAwayTimeout).toBe(20.0);
135135

136-
// Legacy options should be stripped
137-
expect('turnDetection' in result).toBe(false);
138-
expect('voiceOptions' in result).toBe(false);
136+
// Legacy options should still be available
137+
expect('turnDetection' in result).toBeDefined();
138+
expect('voiceOptions' in result).toBeDefined();
139139
});
140140

141141
it('should preserve non-legacy options in the result', () => {
@@ -155,9 +155,9 @@ describe('migrateLegacyOptions', () => {
155155
expect(result.maxToolSteps).toBe(5);
156156
expect(result.connOptions).toEqual({ maxUnrecoverableErrors: 10 });
157157

158-
// Legacy options should be stripped and migrated
159-
expect('turnDetection' in result).toBe(false);
160-
expect('voiceOptions' in result).toBe(false);
158+
// Legacy options should still be available and mirror the new options
159+
expect(result.turnDetection).toBe('vad');
160+
expect(result.voiceOptions?.minEndpointingDelay).toBe(1.0);
161161
expect(result.turnHandling!.turnDetection).toBe('vad');
162162
expect(result.turnHandling!.endpointing!.minDelay).toBe(1.0);
163163
});

agents/src/voice/turn_config/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ export function migrateLegacyOptions<UserData>(
3232
...rest.turnHandling,
3333
};
3434

35-
const newAgentSessionOptions: AgentSessionOptions<UserData> = { ...rest, turnHandling };
35+
const newAgentSessionOptions: AgentSessionOptions<UserData> = {
36+
...rest,
37+
turnDetection: turnHandling.turnDetection,
38+
turnHandling,
39+
};
3640

3741
if (voiceOptions?.allowInterruptions === false) {
3842
turnHandling.interruption.mode = false;

0 commit comments

Comments
 (0)