Bug Description
According to deepwiki https://deepwiki.com/search/can-fallbackrealtimesession-im_15e6ca5e-6280-4091-b3d6-65ddfb72aedf?mode=deep,
for livekit.agents.llm.RealtimeModelAapter, openai specific realtime session event handlers are attached to its child realtime session and handlers for general reatime session event in
|
_FORWARDED_EVENTS: tuple[EventTypes, ...] = ( |
) are forwarded to attached to its
parent realtime session.
According to source codes, when implementing llm.restart_session(switch_model=False) , its old child realtime session are closed and discarded and its parent realtime session only keep those handlers of those general realtime session event, and thus all attached plugin-specific realtime session event handlers (eg. openai specific realtime event handlers etc.) will lose
We think this is not a right behavior since you mentioned livekit.agents.llm.RealtimeModelAapter will preserve the agent's bound event handlers in PR #6282.
Please correct the source code so that all attached plugin-specific realtime session event handlers should be automatically forwarded to the new child realtime session if llm.restart_session(switch_model=False) is implemented.
Expected Behavior
all attached plugin-specific realtime session event handlers should be automatically forwarded to the new child realtime session if llm.restart_session(switch_model=False) is implemented.
Reproduction Steps
- set
llm=RealtimeModelFallbackAdapter(
[openai.realtime.RealtimeModel(),
openai.realtime.RealtimeModel.with_azure()]
)
- attach openai-specific realtime session event handlers:
rt_session = agent.realtime_llm_session
@rt_session._active.on("openai_server_event_received")
def on_openai_server_event_received(event: dict[str, Any]) -> None:
logger.info("openai_server_event_received handling"
- implement
await agent.llm.restart_session(switch_model=False)
- try to simulate to emit "openai_server_event_received" realtime session event
- check whether the attached openai-specific realtime session event handlers still work
Operating System
MacOS, linux
Models Used
Openai gpt-realtime, Azure gpt-realtime
Package Versions
livekit=1.1.13
livekit-agents=1.6.6
livekit-api=1.2.0
Session/Room/Call IDs
No response
Proposed Solution
Additional Context
No response
Screenshots and Recordings
No response
Bug Description
According to deepwiki https://deepwiki.com/search/can-fallbackrealtimesession-im_15e6ca5e-6280-4091-b3d6-65ddfb72aedf?mode=deep,
for
livekit.agents.llm.RealtimeModelAapter, openai specific realtime session event handlers are attached to its child realtime session and handlers for general reatime session event inagents/livekit-agents/livekit/agents/llm/realtime_fallback_adapter.py
Line 58 in 87ef1b1
According to source codes, when implementing llm.restart_session(switch_model=False) , its old child realtime session are closed and discarded and its parent realtime session only keep those handlers of those general realtime session event, and thus all attached plugin-specific realtime session event handlers (eg. openai specific realtime event handlers etc.) will lose
We think this is not a right behavior since you mentioned
livekit.agents.llm.RealtimeModelAapterwill preserve the agent's bound event handlers in PR #6282.Please correct the source code so that all attached plugin-specific realtime session event handlers should be automatically forwarded to the new child realtime session if llm.restart_session(switch_model=False) is implemented.
Expected Behavior
all attached plugin-specific realtime session event handlers should be automatically forwarded to the new child realtime session if
llm.restart_session(switch_model=False)is implemented.Reproduction Steps
Operating System
MacOS, linux
Models Used
Openai gpt-realtime, Azure gpt-realtime
Package Versions
Session/Room/Call IDs
No response
Proposed Solution
Additional Context
No response
Screenshots and Recordings
No response