Skip to content

fix(llm): preserve provider events on restart - #6568

Open
Bortlesboat wants to merge 1 commit into
livekit:mainfrom
Bortlesboat:codex/6559-preserve-realtime-handlers
Open

fix(llm): preserve provider events on restart#6568
Bortlesboat wants to merge 1 commit into
livekit:mainfrom
Bortlesboat:codex/6559-preserve-realtime-handlers

Conversation

@Bortlesboat

Copy link
Copy Markdown

Summary

  • forward provider-specific realtime session events through the fallback wrapper
  • rebind those event forwarders whenever the underlying realtime session is restarted
  • keep subscriptions made during a restart detached from the closing child session

Root cause

The fallback session only forwarded its fixed core event set. Provider-specific events such as openai_server_event_received were available only on the private active child, and that child is replaced by restart_session().

Applications can now subscribe to provider-specific events on the stable fallback session instead:

session.on("openai_server_event_received", handler)

Testing

  • pytest tests/test_realtime_fallback.py -q (38 passed)
  • ruff check livekit-agents/livekit/agents/llm/realtime_fallback_adapter.py tests/test_realtime_fallback.py
  • ruff format --check livekit-agents/livekit/agents/llm/realtime_fallback_adapter.py tests/test_realtime_fallback.py
  • mypy --config-file pyproject.toml --untyped-calls-exclude=smithy_aws_core -p livekit.agents.llm.realtime_fallback_adapter

Fixes #6559

@Bortlesboat
Bortlesboat requested a review from a team as a code owner July 27, 2026 17:10
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

all attached plugin-specific realtime session event handlers lost when retart_session with the same model.

2 participants