g
Hello
t
Thanks for reaching out, YASH. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi — thanks for reaching out! How can I help you today? If you have an issue, please include brief details like your project ID, room ID, SDK (web/iOS/Android), and any error messages or steps to reproduce so I can jump in faster. , with interactive elements
g
Title: Agent goes dead after AWS Bedrock session recycle (LK_SESSION_MAX_DURATION) Background AWS Bedrock Nova Sonic has an 8-minute hard session limit. We set
LK_SESSION_MAX_DURATION=450
(7.5 min) so the plugin recycles the Bedrock WebSocket before AWS forcibly closes it. The plugin's
_graceful_session_recycle()
internally calls
initialize_streams(is_restart=True)
which reopens the Bedrock stream and replays the full
_chat_ctx
as history into the new session. Problem When the Bedrock session recycles at the 450s mark, the agent goes dead. The LiveKit
AgentSession
is still alive, the room is still connected, the caller is still on the line — but the agent stops responding entirely. It does not speak, does not react to user utterances, and the call hangs silently until the watchdog or the caller disconnects. Steps to Reproduce 1. Start a call using Nova Sonic (
amazon.nova-2-sonic-v1:0
) 2. Keep the caller on the line for 7.5+ minutes 3. Observe the Bedrock session recycle at`LK_SESSION_MAX_DURATION`seconds 4. Agent stops responding to all user input after the recycle Expected Behavior After the Bedrock WebSocket recycles, the agent should resume the conversation and continue responding to the caller naturally. Actual Behavior Agent goes completely silent. No errors are thrown to the application level. The
AgentSession
does not emit a recoverable error event. The call hangs until timeout. Environment •
LK_SESSION_MAX_DURATION=450
• Provider: AWS Nova Sonic 2 (
amazon.nova-2-sonic-v1:0
) • LiveKit agents SDK with`livekit-plugins-aws`
t
Thanks — this is clear and helpful. I’m responding about the agent going silent after the Bedrock/Nova Sonic session recycle at your configured
LK_SESSION_MAX_DURATION
. To troubleshoot and narrow the cause I need a few quick details and logs: 1. Which LiveKit Agents SDK version and which plugin package version (
livekit-plugins-aws
) are you running? 2. During a reproduce, can you capture and paste: ◦ Agent-side logs around the 440–470s window (including any debug from the AWS plugin,
initialize_streams
, or
_graceful_session_recycle
). ◦ LiveKit server logs for that room/AgentSession at the same time. 1. Does the agent emit any turn/voice-state events after recycle (e.g., start/stop speaking, generate_reply calls) — even if empty? If you have metrics or event traces, please include them. 2. Do you see any WebSocket disconnect/close frames from the Bedrock side around 480s, or only your intentional recycle at 450s? 3. Are you using Nova Sonic in
modalities: "mixed"
(text+audio) or
audio
only? Are you sending text
generate_reply()
calls, streaming audio, or both? 4. If possible, can you reproduce with a smaller
LK_SESSION_MAX_DURATION
(e.g., 60s) to see whether the behavior consistently follows the recycle step? What I’ll do next after you share the above: • Look for whether the plugin’s restart path restores audio/text streams and re-registers turn handlers. • Check for missing recoverable/error events from AgentSession and whether the agent’s turn state is stuck waiting for an event. • Suggest specific instrumentation or a mitigation (e.g., explicitly re-issuing a conversational prompt or forcing a synthetic turn event after recycle) based on the logs. If you prefer, paste a minimal log excerpt (timestamps + log lines) and I’ll point to the exact lines to inspect. Sources: Amazon Nova Sonic integration guide | LiveKit Documentation | Turn-taking tuning | LiveKit Documentation | Server lifecycle | LiveKit Documentation | AWS AI and LiveKit | LiveKit Documentation, with interactive elements
g
1. SDK versions Check by running:
Copy code
pip show livekit-agents livekit-plugins-aws
From the installed path we can see it's at
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/livekit/
— exact versions needed from pip output. Bash Get exact SDK versions IN
Copy code
pip show livekit-agents livekit-plugins-aws 2>/dev/null | grep -E "^Name:|^Version:"
OUT
Copy code
Name: livekit-agents
Version: 1.5.11
Name: livekit-plugins-aws
Version: 1.5.11
1. SDK Versions • `livekit-agents`:*1.5.11* • `livekit-plugins-aws`:*1.5.11* 2. Agent-side logs around the 440–470s window We reproduced with
LK_SESSION_MAX_DURATION=60
(point 6 below). The plugin logs show:
Copy code
[SESSION] Recycle timer started, will fire in 60s
[SESSION] Session duration limit reached (60s), initiating recycle
[SESSION] Waiting for assistant to finish speaking (AUDIO END_TURN)...
[SESSION] No new audio for 1s, proceeding with recycle
[SESSION] Sending close events to Nova Sonic...
[SESSION] Generation completed (completionEnd received)
[SESSION] Starting graceful session recycle
[SESSION] Draining pending tool results...
[SESSION] No more pending tool results
[SESSION] Response task timeout, cancelling...
[SESSION] Session recycled successfully
After
Session recycled successfully
— no further agent-side logs appear. No
generate_reply
, no turn events, no errors. The agent is alive but silent. 3. Turn/voice-state events after recycle None. After
Session recycled successfully
the
AgentSession
emits no
agent_state_changed
, no
user_input_transcribed
reactions, no
conversation_item_added
. User audio is still flowing (we can see raw ASR from the STT side) but the agent produces zero output.
generate_reply
is never triggered by user speech after the recycle. 4. WebSocket disconnect/close frames from Bedrock Only the intentional recycle close events at
LK_SESSION_MAX_DURATION
. No unexpected Bedrock-side WebSocket close frames observed before that. The recycle sequence completes cleanly (
Session recycled successfully
) — the issue is not a crash or error, it's a silent dead state after a clean recycle. 5. Modalities and generate_reply usage
Copy code
aws.realtime.RealtimeModel(
    modalities="mixed",      # text + audio
    model="amazon.nova-2-sonic-v1:0",
    turn_detection="MEDIUM",
    tool_choice="auto",
    temperature=0.1,
    top_p=0.9,
)
• Both audio streaming and`generate_reply()`(text instruction calls) are used. • `generate_reply(user_input="Hello")`is used on`on_enter`for the opening greeting. • `generate_reply(instructions="...")`is used for tool-driven responses and transfers. • After recycle,neither audio nor text triggers any model response. 6. Reproduced with LK_SESSION_MAX_DURATION=60 Yes — confirmed. The behavior follows the recycle step consistently at any duration. With
LK_SESSION_MAX_DURATION=60
the agent goes dead reliably at ~60s. The recycle itself completes without error (
Session recycled successfully
is logged), but the agent never responds to user speech again after that point. Key observation: The new Bedrock session opens successfully (we see
AWS Bedrock Realtime Session Started
logged with a new
bedrock_session_id
), so the WebSocket reconnection works. The failure is that user audio input no longer triggers any model turn after the recycle — suggesting the audio input pipeline or turn detection is not re-attached to the new session.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!