-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Bug Description
Description
The issue reported in #4152 is still present in v1.3.9. The ctx.add_shutdown_callback is not being triggered, and the agent appears to get "stuck" during the closing process.
Root Cause Detail
I have identified that if the agent is configured to give a greeting message using session.say or session.generate_reply inside Agent.on_enter (or immediately after the session starts), the agent gets stuck while closing if no participant ever successfully joined the room (e.g., the SIP call was never answered).
The fix provided in v1.3.9 does not seem to have resolved the problem for SIP participants.
Environment
- Package:
livekit-agents - Version:
1.3.9 - Previous working version:
1.2.18
Expected Behavior
The shutdown callback should be executed regardless of whether the SIP call was answered or how it was terminated, as it did in version 1.2.18.
Reproduction Steps
I am using the following logic, and the callback is never reached if the SIP call fails to connect or is hung up:
async def entrypoint(ctx: JobContext):
async def shutdown_handler():
print("Shutdown callback executed successfully")
ctx.add_shutdown_callback(shutdown_handler)
# Triggering outbound SIP call
# The callback is NOT called if the call is rejected or unanswered.Operating System
Windows 11
Models Used
No response
Package Versions
livekit-agents==1.3.9Session/Room/Call IDs
No response
Proposed Solution
Additional Context
No response
Screenshots and Recordings
No response