Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions assistant/src/calls/call-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,7 @@ export class CallController {
private isExpectedAbortError(err: unknown): boolean {
if (!(err instanceof Error)) return false;
return err.name === 'AbortError'
|| err.name === 'APIUserAbortError'
|| err.message === 'Session is already processing a message';
|| err.name === 'APIUserAbortError';
}

private isCurrentRun(runVersion: number): boolean {
Expand Down
1 change: 1 addition & 0 deletions assistant/src/calls/voice-session-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export async function startVoiceTurn(opts: VoiceTurnOptions): Promise<VoiceTurnH
eventSink,
voiceCallControlPrompt,
},
opts.signal,
);

// If the caller provided an external AbortSignal (e.g. from a
Expand Down
9 changes: 9 additions & 0 deletions assistant/src/runtime/run-orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export class RunOrchestrator {
content: string,
attachmentIds?: string[],
options?: RunStartOptions,
signal?: AbortSignal,
): Promise<RunHandle> {
// Block inbound content that contains secrets — mirrors the IPC check in sessions.ts
const ingressCheck = checkIngressForSecrets(content);
Expand All @@ -200,13 +201,21 @@ export class RunOrchestrator {
if (session.isProcessing()) {
// Voice barge-in can race with turn teardown. Wait briefly for the
// previous run to finish aborting before giving up.
// The caller can pass an AbortSignal so superseded turns bail out
// of this wait early instead of occupying the session.
const maxWaitMs = 3000;
const pollIntervalMs = 50;
let waited = 0;
while (session.isProcessing() && waited < maxWaitMs) {
if (signal?.aborted) {
throw new Error('Run aborted while waiting for session');
}
await new Promise(resolve => setTimeout(resolve, pollIntervalMs));
waited += pollIntervalMs;
}
if (signal?.aborted) {
throw new Error('Run aborted while waiting for session');
}
if (session.isProcessing()) {
throw new Error('Session is already processing a message');
}
Expand Down