Skip to content

feat: enable generic serialization for all LiveKit plugins #28

Merged
mahimairaja merged 1 commit intomainfrom
fix/jobcontext-prewarm
Apr 3, 2026
Merged

feat: enable generic serialization for all LiveKit plugins #28
mahimairaja merged 1 commit intomainfrom
fix/jobcontext-prewarm

Conversation

@mahimairaja
Copy link
Copy Markdown
Owner

No description provided.

@mahimairaja mahimairaja self-assigned this Apr 3, 2026
Copilot AI review requested due to automatic review settings April 3, 2026 13:29
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d15171b9-4358-4092-a701-f2d82729c7f9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/jobcontext-prewarm

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mahimairaja mahimairaja merged commit 656726d into main Apr 3, 2026
7 checks passed
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.33%. Comparing base (9e09f70) to head (2ae9adc).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
+ Coverage   90.32%   90.33%   +0.01%     
==========================================
  Files          13       13              
  Lines        1426     1428       +2     
==========================================
+ Hits         1288     1290       +2     
  Misses        138      138              
Files with missing lines Coverage Δ
src/openrtc/pool.py 90.96% <100.00%> (+0.03%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e09f70...2ae9adc. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables generic spawn-safe serialization for LiveKit plugin provider objects by expanding the _opts-based provider reference mechanism beyond the explicitly enumerated OpenAI plugin classes.

Changes:

  • Added a generic _opts-based serialization path for any livekit.plugins.* provider objects.
  • Kept _PROVIDER_REF_KEYS as a fast-path / documentation list for known-tested providers.
  • Added a unit test intended to ensure non-OpenAI plugins using _opts are accepted.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/openrtc/pool.py Extends provider serialization to generically handle livekit.plugins.* objects exposing _opts.
tests/test_pool.py Adds a test case for generic LiveKit plugin acceptance via _opts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +612 to +618
# Generic path: any livekit plugin with _opts
if cls.__module__.startswith("livekit.plugins.") and hasattr(value, "_opts"):
return _ProviderRef(
module_name=cls.__module__,
qualname=cls.__qualname__,
kwargs=_extract_provider_kwargs(value),
)
Copy link

Copilot AI Apr 3, 2026

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 _ProviderRef is pickleable) but then fail during unpickling when _deserialize_provider_value calls importlib.import_module(...) / _resolve_qualname(...). Consider guarding the generic path by confirming the module can be imported (or at least importlib.util.find_spec is not None) and that _opts is non-None, otherwise fall back to the existing pickleability check so failures happen at registration time rather than in the worker.

Copilot uses AI. Check for mistakes.
Comment on lines +272 to +286
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
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This test only asserts that pool.add(...) does not raise, but it doesn't validate the intended behavior (pickle/rehydration via the generic _opts path). As written, it also sets model as a class attribute on FakeOpts, so _extract_provider_kwargs (which uses vars(options)) will extract {} and drop model, making the test pass even if option serialization is broken. To properly cover the new behavior, ensure the fake plugin module/class is importable (e.g., via a temporary module in sys.modules) and assert a pickle round-trip restores the provider type and preserves extracted kwargs like model.

Copilot uses AI. Check for mistakes.
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