diff --git a/agents/src/voice/agent_activity.ts b/agents/src/voice/agent_activity.ts index db16674e5..28e2418fd 100644 --- a/agents/src/voice/agent_activity.ts +++ b/agents/src/voice/agent_activity.ts @@ -2183,6 +2183,10 @@ export class AgentActivity implements RecognitionHooks { if (!ignoreTaskSwitch && newAgentTask !== null) { this.agentSession.updateAgent(newAgentTask); draining = true; + // Skip chat context update and reply creation - the new agent will handle this. + // The old realtime session is being closed by updateAgent(), so we cannot + // continue using this.realtimeSession after this point. + return; } if (functionToolsExecutedEvent.functionCallOutputs.length > 0) {