-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: enable generic serialization for all LiveKit plugins #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -269,6 +269,23 @@ def test_agent_config_is_pickleable_with_openai_provider_objects( | |
| assert restored.tts.__class__.__module__ == "livekit.plugins.openai.tts" | ||
|
|
||
|
|
||
| def test_generic_livekit_plugin_with_opts_is_accepted() -> None: | ||
| """Non-OpenAI livekit plugins with ``_opts`` should serialize via the generic path.""" | ||
|
|
||
| class FakeOpts: | ||
| model = "nova-3" | ||
|
|
||
| # Create a class whose module looks like a livekit plugin | ||
| FakeSTT = type("STT", (), {"__module__": "livekit.plugins.deepgram.stt"}) | ||
| instance = FakeSTT() | ||
| instance._opts = FakeOpts() # type: ignore[attr-defined] | ||
|
|
||
| pool = AgentPool() | ||
| # Should not raise — the generic _opts path handles it | ||
| config = pool.add("test", DemoAgent, stt=instance) | ||
| assert config.stt is not None | ||
|
Comment on lines
+272
to
+286
|
||
|
|
||
|
|
||
| def test_list_agents_returns_registration_order() -> None: | ||
| pool = AgentPool() | ||
| pool.add("restaurant", DemoAgent) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generic provider-ref path triggers purely on
cls.__module__.startswith('livekit.plugins.')+hasattr(value, '_opts'), without verifying that the referenced module/class is actually importable/resolvable. This can make a config appear spawn-safe (because_ProviderRefis pickleable) but then fail during unpickling when_deserialize_provider_valuecallsimportlib.import_module(...)/_resolve_qualname(...). Consider guarding the generic path by confirming the module can be imported (or at leastimportlib.util.find_specis notNone) and that_optsis non-None, otherwise fall back to the existing pickleability check so failures happen at registration time rather than in the worker.