Skip to content

fix(llm): drop nonexistent name from __all__ - #7894

Merged
davidzhao merged 1 commit into
livekit:mainfrom
BlueX888:fix/stale-star-import-export
Oct 17, 2026
Merged

davidzhao merged 1 commit into
livekit:mainfrom
BlueX888:fix/stale-star-import-export

Conversation

@BlueX888

Copy link
Copy Markdown
Contributor

What does this PR fix?

livekit.agents.llm.__all__ listed RealtimeSessionRestoredEvent, but no such class exists anywhere in the package — realtime.py only defines RealtimeSessionReconnectedEvent. The dangling entry breaks the module's public import surface:

  • from livekit.agents.llm import * fails immediately, because a star import resolves every __all__ name against the module: AttributeError: module 'livekit.agents.llm' has no attribute 'RealtimeSessionRestoredEvent' (the did-you-mean suggestion machinery has existed since Python 3.10, so all supported versions show it). A named import of the missing name instead raises ImportError: cannot import name ... on every Python version.
  • from livekit.agents import llm followed by llm.RealtimeSessionRestoredEvent raises AttributeError at attribute-access time.

Any user code doing a star import of the module — or tooling that consumes __all__ to enumerate the public API (docs generation, stub builders, linters) — hits this on current main.

Root cause

The entry was born dangling: RealtimeSessionReconnectedEvent exists in realtime.py, but RealtimeSessionRestoredEvent never existed in any released version (verified against the published 1.1.0–1.8.8 wheels — the name appears only as this __all__ string), so the __all__ entry was most likely a typo'd or placeholder name for its sibling that no import ever validated. __all__ is a plain string list with no runtime check tying it to the module contents, so importing livekit.agents.llm itself still succeeds and nothing flagged the entry; it only surfaces when the name is actually resolved.

The fix

Remove the single stale "RealtimeSessionRestoredEvent" entry from __all__ in livekit-agents/livekit/agents/llm/__init__.py. It is the only entry without a backing attribute — all 78 other exports resolve. A repo-wide search confirms the name appears nowhere else; the only occurrence was the stale __all__ entry.

Testing

Adds tests/test_llm_exports.py:

  • test_public_llm_exports_resolve — asserts every name in llm.__all__ is a real attribute of the module (mirrors the existing test_public_inference_exports_resolve in tests/test_inference_utils.py), so any future stale, removed, or renamed export is caught, not just this one.
  • test_llm_star_import_resolves_every_export — executes from livekit.agents.llm import * and checks every __all__ name is bound.

Both tests fail on main at the stale entry:

AssertionError: llm.__all__ lists 'RealtimeSessionRestoredEvent', but livekit.agents.llm does not define it
AttributeError: module 'livekit.agents.llm' has no attribute 'RealtimeSessionRestoredEvent'. Did you mean: 'RealtimeSessionReconnectedEvent'?

and pass with this change. The surrounding llm unit tests (chat context, decisions, tools, fallback, cache breakpoints, inference utils, chat-item proto coverage, ...) still pass; the single failure in tests/test_duplex_adapter.py reproduces identically on main without this change and is unrelated.

@BlueX888
BlueX888 requested a review from a team as a code owner October 17, 2026 06:06

@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.

Devin Review

@davidzhao

Copy link
Copy Markdown
Member

please remove the test file, it doesn't add any value

RealtimeSessionRestoredEvent is listed in llm.__all__ but no such class
exists anywhere in the package (it never existed in any released
version), so both `from livekit.agents.llm import *` and plain
attribute access raise AttributeError on every supported Python.
Remove the stale entry.
@BlueX888
BlueX888 force-pushed the fix/stale-star-import-export branch from 7cd8996 to b48552b Compare October 17, 2026 08:03
@BlueX888

Copy link
Copy Markdown
Contributor Author

Thanks @davidzhao — done, the test file is removed. The branch is now just the one-line change dropping the nonexistent RealtimeSessionRestoredEvent from llm.__all__, and it is rebased onto current main. Every remaining __all__ entry resolves, from livekit.agents.llm import * works again, and the existing llm unit tests still pass.

@davidzhao davidzhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks, lg

@davidzhao
davidzhao merged commit 01fb91f into livekit:main Oct 17, 2026
15 checks passed
BlueX888 added a commit to BlueX888/BlueX888 that referenced this pull request Oct 18, 2026
- 新增缺陷表行:livekit/agents #7892/#7893/#7895/#7896/#7899(直接提 PR)、
  agno-agi/agno #11132(修复 #10271 已提交)、
  PrefectHQ/fastmcp #5780/#5781/#5782/#5799/#5800/#5801/#5802(已提交,等待确认)
- deer-flow #7002 状态补「已合并」(2026-10-17 合入)
- deer-flow issue #5846 记为「已被上游修复」(#7020 合并后关闭)
- NOTES 补 deer-flow#7002 与 livekit/agents#7894 的根因说明,贡献区刷新为 32 个已合并 PR
- 缺陷统计随之刷新(214 条 / 35 仓库)
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.

2 participants