fix(voice): disable AEC warmup for outbound SIP calls - #2202
Conversation
🦋 Changeset detectedLatest commit: 2a88a3a The changes in this PR will be included in the next version bump. This PR includes changesets to release 39 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| } | ||
|
|
||
| this.participantAvailableFuture.resolve(participant); | ||
| this.agentSession._onRoomIOParticipantLinked(participant); |
There was a problem hiding this comment.
🟡 Echo-cancellation warmup is not disabled for outbound phone calls when the caller is already in the room
The session is only told about the linked caller from the connect path (this.agentSession._onRoomIOParticipantLinked(participant) at agents/src/voice/room_io/room_io.ts:262) and not from the path that switches to a caller that has already joined, so those outbound phone calls keep the 3-second interruption block.
Impact: For outbound calls where the callee is already present when the agent focuses on them, early speech from the callee is still ignored during the greeting.
Two code paths resolve the linked participant, only one notifies the session
RoomIO.setParticipant() also resolves participantAvailableFuture directly when the target participant is already in room.remoteParticipants (agents/src/voice/room_io/room_io.ts:473-483) and never calls _onRoomIOParticipantLinked. This public method is the documented way to focus the session on a SIP callee (see examples/src/telephony_amd.ts:75). If the SIP participant is created before setParticipant is called, the linked-participant hook never runs and sessionOptions.aecWarmupDuration stays at the 3000 ms default even for an outbound SIP call, which is exactly the case this PR aims to fix.
Prompt for agents
RoomIO has two places where the linked participant future gets resolved: onParticipantConnected (agents/src/voice/room_io/room_io.ts:261) and setParticipant (around agents/src/voice/room_io/room_io.ts:473-483, when the target participant is already connected). The PR only notifies AgentSession from the first one, so outbound SIP detection is skipped when the session is switched onto an already-connected SIP participant (a supported flow, see examples/src/telephony_amd.ts). Consider extracting a single helper that resolves the future and notifies the session, and use it in both places.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
It is unclear why you would have another participant before a SIP call and have the callee waiting on the line? In that case, it is almost like an inbound call.
|
Filed AGT-3217 as a follow-up to make AEC warmup re-arming participant-aware. It covers same-participant reconnects vs. genuinely new acoustic endpoints, plus the Python/JS timer-lifecycle difference when relinking while the agent is already speaking. Treating this as non-blocking for this PR so the outbound SIP fix can merge first. |
Ports livekit/agents#6608.
Outbound SIP callers can speak before the greeting, but the default AEC warmup suppresses those initial interruptions. Detect outbound SIP participants through the empty
sip.ruleIDattribute and disable warmup only whenaecWarmupDurationis omitted; explicit settings and the 3000 ms default for other calls remain unchanged.Validation
pnpm test agents(111 files, 1551 passed, 5 skipped)pnpm buildpnpm lint(passes with existing warnings)pnpm exec prettier --check ...on changed filescue-clivoice-mode run: observedAS_SPEAKINGfollowed by committed assistant greetingSource diff coverage
Source diff coverage
livekit-agents/livekit/agents/voice/agent_session.py->agents/src/voice/agent_session.ts. Preserves omitted-vs-explicit AEC configuration, adapts the 3.0-second Python default to 3000 ms, detects outbound SIP via rtc-nodeparticipant.info.kindplus an emptysip.ruleID, updates remaining warmup, and clears an active Node timer.livekit-agents/livekit/agents/voice/room_io/room_io.py->agents/src/voice/room_io/room_io.ts. NotifiesAgentSessionimmediately after resolving the linked participant.tests/test_agent_session.py->agents/src/voice/agent_session.test.ts. Ports the source parameterized coverage for call-type defaults, explicit overrides, and active timer cancellation using Vitest and rtc-node conventions.Ported from livekit/agents#6608
Original PR description
Outbound SIP callers can speak before the greeting, but the default AEC warmup suppresses those initial interruptions. Detect outbound SIP participants through the empty sip.ruleID attribute and disable warmup only when the option is omitted; explicit settings and the three-second default for other calls remain unchanged.
Tested with a SIP outbound call.
Fixes AGT-3199