Skip to content

Docs, discovery behavior, and dependency updates; add CONTRIBUTING.md#8

Merged
mahimairaja merged 1 commit intomainfrom
feat/plan-milestone-4-and-remove-agent_-support
Mar 19, 2026
Merged

Docs, discovery behavior, and dependency updates; add CONTRIBUTING.md#8
mahimairaja merged 1 commit intomainfrom
feat/plan-milestone-4-and-remove-agent_-support

Conversation

@mahimairaja
Copy link
Copy Markdown
Collaborator

@mahimairaja mahimairaja commented Mar 19, 2026

Motivation

  • Improve contributor onboarding with a CONTRIBUTING.md and expand the user-facing documentation in README.md with examples and behavioral details.
  • Standardize discovery metadata on a decorator-based API and simplify discovery fallbacks to filename and pool defaults to make discovered agents predictable and backward-compatible with pool defaults.
  • Align packaging metadata and resolver state with the runtime requirements by adding livekit-agents and optional extras, plus updated lockfile entries for reproducible installs.

Description

  • Add CONTRIBUTING.md with local setup, commands, architecture notes, and contribution/testing expectations.
  • Rewrite and expand README.md to document purpose, quick-start examples for AgentPool.add() and discovery with @agent_config(...), routing rules, provider examples, CLI usage, and migration guidance.
  • Modify AgentPool in src/openrtc/pool.py to prefer decorator metadata for discovery, return an empty AgentDiscoveryConfig() when no decorator is present (removing legacy AGENT_* module-level parsing), adjust docstrings, and remove _read_module_str helper.
  • Update tests in tests/test_discovery.py to reflect the new discovery behavior (filename fallback and pool defaults) and updated expectations.
  • Update pyproject.toml to add livekit-agents and optional extras, add pytest-asyncio to dev deps, and export package metadata, and replace uv.lock with a comprehensive regenerated lockfile including added dependencies and extras.

Testing

  • Ran unit test suite with uv run pytest (equivalent to pytest) and the modified discovery tests in tests/test_discovery.py passed.
  • Ran lint/format checks with uv run ruff check and formatting where applicable; no blocking issues remained after changes.

Codex Task

Summary by CodeRabbit

Release Notes

  • Documentation

    • Added comprehensive contribution guidelines.
    • Expanded README with clearer setup instructions, quick-start examples, provider configuration, CLI commands, and migration guide from legacy agent configuration.
  • Dependencies

    • Added livekit-agents as a core dependency.
  • Behavior Change

    • Agent discovery now exclusively uses the @agent_config(...) decorator; legacy module-level metadata configuration is no longer supported.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

This pull request consolidates OpenRTC's documentation, updates project dependencies to include livekit-agents as a core requirement, and removes legacy module-level discovery metadata support in favor of decorator-based configuration and pool defaults.

Changes

Cohort / File(s) Summary
Documentation
CONTRIBUTING.md, README.md
New contributor guide and extensive README rewrite covering development workflow, architecture responsibilities, contribution rules, installation, quick-start paths, routing behavior, provider model strings, CLI commands, and migration guide from legacy module globals to @agent_config(...) decorator pattern.
Dependencies
pyproject.toml
Added livekit-agents~=1.4 to core [project].dependencies; introduced [project.optional-dependencies] table with common extra referencing livekit-agents[silero,turn-detector]~=1.4.
Core Implementation
src/openrtc/pool.py
Updated AgentPool docstrings to clarify default provider/greeting behavior; removed _read_module_str() helper; changed _resolve_discovery_metadata() to return empty config when no @agent_config(...) decorator is present, discontinuing support for legacy module-level attributes (AGENT_NAME, AGENT_STT, etc.).
Tests
tests/test_discovery.py
Replaced legacy module-level metadata test with test_discover_uses_filename_and_pool_defaults_without_decorator; now validates filename-derived agent naming and pool default population when no decorator is present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • PR #2: Adds foundational AgentPool and discovery logic that this PR refines by removing legacy module-level metadata support.
  • PR #3: Introduces decorator-based metadata resolution (@agent_config(...)) that this PR completes by removing the legacy AGENT_* module attribute fallback path.

Poem

🐰 No more scattered module globals in the fray,
The decorator guides the agent's way!
Pool defaults bloom where config once did sprawl,
A tidy discovery—modern, clean, and all. 🌿✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: documentation updates (CONTRIBUTING.md, README), discovery behavior modifications, and dependency updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/plan-milestone-4-and-remove-agent_-support
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/openrtc/pool.py (1)

359-376: ⚠️ Potential issue | 🔴 Critical

Remove the explicit ctx.connect() call; AgentSession automatically connects via RoomIO when room=ctx.room is passed.

In livekit-agents, AgentSession connects to LiveKit automatically during start() when passed the room parameter. The explicit await ctx.connect() on line 372 is redundant and violates the correct session lifecycle pattern. When using AgentSession with room=ctx.room (as this code does), omit the ctx.connect() call entirely—the framework handles it internally via RoomIO.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openrtc/pool.py` around lines 359 - 376, The explicit await ctx.connect()
in _handle_session should be removed because AgentSession.start(...,
room=ctx.room) already connects via RoomIO; update the _handle_session function
to omit the ctx.connect() call (leave AgentSession(...) construction and await
session.start(agent=config.agent_cls(), room=ctx.room) and the greeting logic
intact) so the session lifecycle is handled solely by AgentSession/RoomIO.
🧹 Nitpick comments (2)
tests/test_discovery.py (1)

9-19: Minor: Template always imports agent_config even when unused.

The _AGENT_TEMPLATE includes from openrtc import agent_config even when the decorator is not used (e.g., in test_discover_uses_filename_and_pool_defaults_without_decorator). This results in an unused import in the generated test modules, but it doesn't affect test correctness.

💡 Optional: Conditionally include the import
 _AGENT_TEMPLATE = """from __future__ import annotations

 from livekit.agents import Agent
-from openrtc import agent_config

 {config_block}
+{imports}

 {decorator}class {class_name}(Agent):
     def __init__(self) -> None:
         super().__init__(instructions={instructions!r})
 """

Then update _write_agent_module to include imports="from openrtc import agent_config\n" only when a decorator is specified.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_discovery.py` around lines 9 - 19, The template always includes
"from openrtc import agent_config" which produces an unused import when no
decorator is provided; update the generation so the import is only added when a
decorator is used: remove the hardcoded "from openrtc import agent_config" line
from _AGENT_TEMPLATE and instead pass imports="from openrtc import
agent_config\n" into _write_agent_module only when the {decorator} value is
non-empty (or when a decorator flag is true), ensuring _write_agent_module
receives the imports string conditionally and _AGENT_TEMPLATE only contains the
necessary placeholders ({config_block}, {decorator}, {class_name},
{instructions!r}).
src/openrtc/pool.py (1)

431-440: Unused module parameter after removing legacy metadata support.

The module parameter is no longer used in _resolve_discovery_metadata since the legacy AGENT_* attribute reading was removed. The method now only checks for decorator metadata on agent_cls.

♻️ Consider removing the unused parameter
     def _resolve_discovery_metadata(
         self,
-        module: ModuleType,
         agent_cls: type[Agent],
     ) -> AgentDiscoveryConfig:
         metadata = getattr(agent_cls, _AGENT_METADATA_ATTR, None)
         if metadata is not None:
             return metadata

         return AgentDiscoveryConfig()

And update the call site at line 240:

-            metadata = self._resolve_discovery_metadata(module, agent_cls)
+            metadata = self._resolve_discovery_metadata(agent_cls)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openrtc/pool.py` around lines 431 - 440, The module parameter on
_resolve_discovery_metadata is now unused; remove the module: ModuleType
parameter from the function signature and its internal references, leaving def
_resolve_discovery_metadata(self, agent_cls: type[Agent]) ->
AgentDiscoveryConfig, and keep the existing logic that reads getattr(agent_cls,
_AGENT_METADATA_ATTR, None) and returns AgentDiscoveryConfig() when missing;
update every call site that passed a module argument (calls to
_resolve_discovery_metadata) to call it with only agent_cls so the signature
change is consistent across the codebase.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/openrtc/pool.py`:
- Around line 359-376: The explicit await ctx.connect() in _handle_session
should be removed because AgentSession.start(..., room=ctx.room) already
connects via RoomIO; update the _handle_session function to omit the
ctx.connect() call (leave AgentSession(...) construction and await
session.start(agent=config.agent_cls(), room=ctx.room) and the greeting logic
intact) so the session lifecycle is handled solely by AgentSession/RoomIO.

---

Nitpick comments:
In `@src/openrtc/pool.py`:
- Around line 431-440: The module parameter on _resolve_discovery_metadata is
now unused; remove the module: ModuleType parameter from the function signature
and its internal references, leaving def _resolve_discovery_metadata(self,
agent_cls: type[Agent]) -> AgentDiscoveryConfig, and keep the existing logic
that reads getattr(agent_cls, _AGENT_METADATA_ATTR, None) and returns
AgentDiscoveryConfig() when missing; update every call site that passed a module
argument (calls to _resolve_discovery_metadata) to call it with only agent_cls
so the signature change is consistent across the codebase.

In `@tests/test_discovery.py`:
- Around line 9-19: The template always includes "from openrtc import
agent_config" which produces an unused import when no decorator is provided;
update the generation so the import is only added when a decorator is used:
remove the hardcoded "from openrtc import agent_config" line from
_AGENT_TEMPLATE and instead pass imports="from openrtc import agent_config\n"
into _write_agent_module only when the {decorator} value is non-empty (or when a
decorator flag is true), ensuring _write_agent_module receives the imports
string conditionally and _AGENT_TEMPLATE only contains the necessary
placeholders ({config_block}, {decorator}, {class_name}, {instructions!r}).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 42b5efab-34c9-4a3c-8226-2feb87942b83

📥 Commits

Reviewing files that changed from the base of the PR and between d6bf99f and 9891de2.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • CONTRIBUTING.md
  • README.md
  • pyproject.toml
  • src/openrtc/pool.py
  • tests/test_discovery.py

@mahimairaja mahimairaja merged commit df4eaf0 into main Mar 19, 2026
6 checks passed
@mahimairaja mahimairaja deleted the feat/plan-milestone-4-and-remove-agent_-support branch March 23, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant