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
12 changes: 12 additions & 0 deletions assistant/src/calls/call-orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ export class CallOrchestrator {
if (interruptedInFlight) {
this.abortController.abort();
this.abortController = new AbortController();

// Strip the one-shot [CALL_OPENING] marker from conversation history
Comment thread
noanflaherty marked this conversation as resolved.
// so it doesn't leak into subsequent LLM requests after barge-in.
// Without this, the consecutive-user merge path below would append
// the caller's transcript to the synthetic "[CALL_OPENING]" message,
// causing the model to re-run opener behavior instead of responding
// directly to the caller.
for (const entry of this.conversationHistory) {
if (entry.content.includes(CALL_OPENING_MARKER)) {
entry.content = entry.content.replace(CALL_OPENING_MARKER_REGEX, '').trim();
}
}
Comment thread
noanflaherty marked this conversation as resolved.
}

this.state = 'processing';
Expand Down
14 changes: 11 additions & 3 deletions assistant/src/calls/relay-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,17 @@ export class RelayConnection {
// Create and attach the LLM-driven orchestrator
const orchestrator = new CallOrchestrator(this.callSessionId, this, session?.task ?? null);
this.setOrchestrator(orchestrator);
orchestrator.startInitialGreeting().catch((err) =>
log.error({ err, callSessionId: this.callSessionId }, 'Failed to start initial outbound greeting'),
);

// Skip the LLM-driven opener when a static welcome greeting is already
// configured via CALL_WELCOME_GREETING — Twilio's ConversationRelay will
// speak it at the transport level, so firing the orchestrator opener too
// would cause a double greeting.
const hasStaticGreeting = !!process.env.CALL_WELCOME_GREETING?.trim();
if (!hasStaticGreeting) {
orchestrator.startInitialGreeting().catch((err) =>
log.error({ err, callSessionId: this.callSessionId }, 'Failed to start initial outbound greeting'),
);
}
}

private async handlePrompt(msg: RelayPromptMessage): Promise<void> {
Expand Down
Loading