Skip to content

feat(examples): update 030-livekit-agents-python#234

Closed
github-actions[bot] wants to merge 4 commits intomainfrom
example/update-030-livekit-agents-python
Closed

feat(examples): update 030-livekit-agents-python#234
github-actions[bot] wants to merge 4 commits intomainfrom
example/update-030-livekit-agents-python

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 15, 2026

Closes #225

Action: Modify
Runtime: python
Example: 030-livekit-agents-python


Build summary

✅ Agent completed successfully after 6 turns.
Rules fired: none


Tests

tests/test_example.py

import os
import sys
from pathlib import Path

# ── Credential check ────────────────────────────────────────────────────────
env_example = Path(__file__).parent.parent / ".env.example"
required = [
    line.split("=")[0].strip()
    for line in env_example.read_text().splitlines()
    if line and not line.startswith("#") and "=" in line and line[0].isupper()
]
missing = [k for k in required if not os.environ.get(k)]
if missing:
    print(f"MISSING_CREDENTIALS: {','.join(missing)}", file=sys.stderr)
    sys.exit(2)
# ────────────────────────────────────────────────────────────────────────────

# We can't run the full LiveKit agent in CI (it needs a running LiveKit server
# and a real room), but we CAN verify that the agent module is structurally
# correct and wired to Deepgram correctly.

sys.path.insert(0, str(Path(__file__).parent.parent / "src"))


def test_agent_module_imports():
    """Importing the agent module verifies all dependencies are installed
    and the code is syntactically valid."""
    import agent  # noqa: F401

    print("Agent module imports correctly")


def test_voice_assistant_class():
    """Verify VoiceAssistant is defined and is a subclass of Agent."""
    from livekit.agents import Agent
    import agent

    assert issubclass(agent.VoiceAssistant, Agent), \
        "VoiceAssistant must subclass livekit.agents.Agent"
    assert hasattr(agent.VoiceAssistant, "on_enter"), \
        "VoiceAssistant must define on_enter lifecycle hook"

    print("VoiceAssistant class is correctly defined")


def test_entrypoint_is_callable():
    """Verify the entrypoint session function is defined and callable."""
    import agent

    assert callable(agent.entrypoint), \
        "entrypoint must be a callable (async function decorated with @server.rtc_session)"

    print("entrypoint is callable")


def test_deepgram_stt_configured():
    """Verify the agent source code references Deepgram's nova-3 STT model.

    We inspect the source directly because the LiveKit inference.STT call can't
    be instantiated outside a running agent process. This confirms the Deepgram
    plugin is wired in correctly.
    """
    src = (Path(__file__).parent.parent / "src" / "agent.py").read_text()

    assert "deepgram/nova-3" in src, \
        "agent.py must configure Deepgram nova-3 via inference.STT('deepgram/nova-3')"
    assert "DEEPGRAM_API_KEY" in src or "inference.STT" in src, \
        "agent.py must use Deepgram STT"

    print("Deepgram STT (nova-3) is configured in entrypoint")


def test_server_object_exists():
    """Verify the AgentServer object is created at module level."""
    import agent
    from livekit.agents import AgentServer

    assert isinstance(agent.server, AgentServer), \
        "agent.server must be an AgentServer instance"

    print("AgentServer instance exists at module level")


if __name__ == "__main__":
    test_agent_module_imports()
    test_voice_assistant_class()
    test_entrypoint_is_callable()
    test_deepgram_stt_configured()
    test_server_object_exists()
    print("\nAll tests passed")

Test output

ℹ️ Turn 1/150 — turn=1 phases=[] tests=not yet run history_len=0
ℹ️ Turn 2/150 — turn=2 phases=[] tests=not yet run history_len=0
### `run_command`: `pytest tests/test_example.py`
**exit**: `127`
bash: line 1: pytest: command not found
ℹ️ Turn 3/150 — turn=3 phases=[] tests=failing history_len=1
### `run_command`: `pip install pytest`
**exit**: `0`
Collecting pytest
  Downloading pytest-9.0.3-py3-none-any.whl.metadata (7.6 kB)
Collecting iniconfig>=1.0.1 (from pytest)
Collecting packaging>=22 (from pytest)
Collecting pluggy<2,>=1.5 (from pytest)
Collecting pygments>=2.7.2 (from pytest)
Downloading pytest-9.0.3-py3-none-any.whl (375 kB)
Installing collected packages: pygments, pluggy, packaging, iniconfig, pytest
Successfully installed iniconfig-2.3.0 packaging-26.1 pluggy-1.6.0 pygments-2.20.0 pytest-9.0.3
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
ℹ️ Turn 4/150 — turn=4 phases=[] tests=passing history_len=2
ℹ️ Turn 5/150 — turn=5 phases=[] tests=passing history_len=2
ℹ️ Turn 6/150 — turn=6 phases=[] tests=passing history_len=2

needs-credentials — one or more tests exit 2 when credentials are missing. Add the required secrets to the repository to enable end-to-end testing.

@github-actions github-actions bot added type:example New example app automated Opened by the build pipeline needs-credentials Example needs secrets added to CI before tests can run end-to-end labels Apr 15, 2026
@github-actions github-actions bot changed the title feat(examples): update 030-livekit-agents-python [WIP] feat(examples): update 030-livekit-agents-python Apr 15, 2026
@github-actions github-actions bot marked this pull request as ready for review April 15, 2026 09:46
@github-actions github-actions bot changed the title feat(examples): update 030-livekit-agents-python feat(examples): update 030-livekit-agents-python [WIP] Apr 15, 2026
@github-actions github-actions bot changed the title feat(examples): update 030-livekit-agents-python [WIP] feat(examples): update 030-livekit-agents-python Apr 15, 2026
@lukeocodes lukeocodes closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Opened by the build pipeline needs-credentials Example needs secrets added to CI before tests can run end-to-end type:example New example app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

livekit guides to demos

1 participant