Skip to content

Conversation

@tschellenbach
Copy link
Member

@tschellenbach tschellenbach commented Nov 5, 2025

This pull request contains changes generated by a Cursor Cloud Agent

Open in Cursor Open in Web

Summary by CodeRabbit

  • Refactor
    • Restructured agent initialization patterns across all examples with a unified launcher-based architecture for improved code organization and maintainability.
    • Separated agent configuration from call joining operations through dedicated factory functions for better modularity.
    • Introduced consistent CLI-driven execution model across all example implementations.
    • Enhanced code reusability and customization patterns throughout example applications.

Updated all examples to follow the modern pattern:
- Split into create_agent() and join_call() functions
- Use await agent.create_user() for user creation
- Use await agent.create_call(call_type, call_id) for call creation
- Use cli(AgentLauncher(...)) in main block
- Add proper logging imports and logger instances

This makes all examples consistent with the openai_realtime_example.py pattern.
@cursor
Copy link

cursor bot commented Nov 5, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link

coderabbitai bot commented Nov 5, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR unifies example syntax across the codebase by introducing a CLI-based launcher pattern. All examples are refactored to expose create_agent and join_call functions wired into AgentLauncher, replacing inline asyncio-based entry points. The core agents module removes unused imports and simplifies create_call invocation.

Changes

Cohort / File(s) Change Summary
Core Agent Implementation
agents-core/vision_agents/core/agents/agents.py
Removed Coroutine import and Call from getstream imports; simplified create_call to await without capturing response variable.
Simple & Golf Coach Examples
examples/01_simple_agent_example/simple_agent_example.py, examples/02_golf_coach_example/golf_coach_example.py
Added logging, replaced start_agent() with create_agent(**kwargs) -> Agent factory and new join_call(...) handler; rewired main entry to cli(AgentLauncher(create_agent=create_agent, join_call=join_call)).
GitHub MCP Demo Examples
examples/other_examples/09_github_mcp_demo/{gemini_realtime_github_mcp_demo.py, github_mcp_demo.py, openai_realtime_github_mcp_demo.py}
Refactored start_agentcreate_agent(**kwargs) -> Agent with explicit error handling; added join_call coroutine to handle participant join events and call lifecycle; replaced direct asyncio entry with launcher-based CLI wiring.
Gemini Live Realtime Example
examples/other_examples/gemini_live_realtime/gemini_live_example.py
Replaced AsyncStream workflow with Agent-driven flow; introduced create_agent(**kwargs) -> Agent and join_call(...) handler; updated main to use launcher pattern.
Plugin Examples — STT/VAD
examples/other_examples/plugins_examples/{stt_deepgram_transcription, stt_moonshine_transcription, vad_silero}/main.py
Added create_agent(**kwargs) -> Agent with STT/VAD event subscriptions and join_call(...) for call management; replaced main() with launcher-based orchestration; added logging setup.
Plugin Examples — TTS
examples/other_examples/plugins_examples/{tts_cartesia, tts_elevenlabs, tts_kokoro}/main.py
Introduced create_agent(**kwargs) -> Agent with TTS configuration and join_call(...) handler; migrated from inline workflows to launcher-driven entry point; added logging infrastructure.
Plugin Examples — MCP & Moderation
examples/other_examples/plugins_examples/{audio_moderation, mcp, video_moderation, wizper_stt_translate}/main.py
Added create_agent(**kwargs) -> Agent factory (including new ExampleMCPServer class for MCP example); introduced join_call(...) for call lifecycle and user creation; replaced main orchestration with cli(AgentLauncher(...)) pattern; added module-level logger and Stream client initialization.

Sequence Diagram

sequenceDiagram
    participant CLI
    participant AgentLauncher
    participant create_agent
    participant join_call
    participant Agent
    participant Call

    CLI->>AgentLauncher: cli(AgentLauncher(create_agent, join_call))
    AgentLauncher->>create_agent: invoke create_agent(**kwargs)
    create_agent->>Agent: initialize with config (LLM, STT, TTS, etc.)
    create_agent-->>AgentLauncher: return Agent instance
    AgentLauncher->>join_call: invoke join_call(agent, call_type, call_id)
    join_call->>Agent: ensure user created via agent.create_user()
    join_call->>Agent: create call via agent.create_call(call_type, call_id)
    Agent->>Call: establish call connection
    join_call->>Call: open_demo()
    join_call->>Agent: participate in call (send/receive)
    join_call-->>AgentLauncher: complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Highlights requiring attention:
    • Core agents.py change: verify create_call behavior without response capture is correct across all calling paths
    • Launcher pattern consistency: ensure all examples follow the same create_agent/join_call signature and behavior conventions
    • Event handling migrations: confirm event subscriptions remain properly wired in refactored create_agent functions across plugin examples
    • MCP example: new ExampleMCPServer class and tool registration logic requires careful review

Possibly related PRs

Suggested labels

cli

Suggested reviewers

  • Nash0x7E2
  • maxkahan
  • yarikdevcom

Poem

The code unites in launcher's gleam,
where create_agent spins its dream—
join_call beckons from the void,
old asyncio cast, destroyed.
Unified syntax, cold and bright,
marching through the example night.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/update-and-refactor-example-code-84d9

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7029f91 and bd8399c.

📒 Files selected for processing (17)
  • agents-core/vision_agents/core/agents/agents.py (2 hunks)
  • examples/01_simple_agent_example/simple_agent_example.py (3 hunks)
  • examples/02_golf_coach_example/golf_coach_example.py (3 hunks)
  • examples/other_examples/09_github_mcp_demo/gemini_realtime_github_mcp_demo.py (5 hunks)
  • examples/other_examples/09_github_mcp_demo/github_mcp_demo.py (6 hunks)
  • examples/other_examples/09_github_mcp_demo/openai_realtime_github_mcp_demo.py (5 hunks)
  • examples/other_examples/gemini_live_realtime/gemini_live_example.py (3 hunks)
  • examples/other_examples/plugins_examples/audio_moderation/main.py (4 hunks)
  • examples/other_examples/plugins_examples/mcp/main.py (3 hunks)
  • examples/other_examples/plugins_examples/stt_deepgram_transcription/main.py (2 hunks)
  • examples/other_examples/plugins_examples/stt_moonshine_transcription/main.py (2 hunks)
  • examples/other_examples/plugins_examples/tts_cartesia/main.py (2 hunks)
  • examples/other_examples/plugins_examples/tts_elevenlabs/main.py (2 hunks)
  • examples/other_examples/plugins_examples/tts_kokoro/main.py (2 hunks)
  • examples/other_examples/plugins_examples/vad_silero/main.py (2 hunks)
  • examples/other_examples/plugins_examples/video_moderation/main.py (4 hunks)
  • examples/other_examples/plugins_examples/wizper_stt_translate/main.py (4 hunks)

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.

@tschellenbach
Copy link
Member Author

@cursor and @cursoragent would you be so kind to run

uv run python dev.py check

and fix any mypy/ruff style issues? thx

@cursor
Copy link

cursor bot commented Nov 5, 2025

Perfect! ✅ I've successfully completed the task! Here's what was done:

Summary

Ran uv run python dev.py check and fixed all mypy/ruff style issues:

Issues Fixed:

  1. F811 - Duplicate Call import: Removed the redundant import from getstream.video.async_call and kept only the one from getstream.video.rtc
  2. F841 - Unused variable: Removed the unused response variable in the create_call method

Results:

  • Ruff linting: All checks passed
  • MyPy type checking: No issues found in 63 source files (main package)
  • MyPy plugin type checking: No issues found in 79 source files (plugins)
  • Unit tests: 207 passed, 2 skipped

Commits:

  1. a0c6849 - Refactor: modernize all example code to use AgentLauncher pattern
  2. bd8399c - Fix: resolve ruff linting issues in agents.py (just pushed)

All changes have been pushed to the branch cursor/update-and-refactor-example-code-84d9 and the PR is ready for review! 🎉


Open in Cursor Open in Web

Learn more about Cursor Agents

Fixed two ruff linting errors:
- F811: Removed duplicate Call import from getstream.video.async_call
- F841: Removed unused response variable in create_call method

All checks now pass (ruff, mypy, and tests).
@tschellenbach tschellenbach changed the title Update and refactor example code [AI-262] Update and refactor example code Nov 5, 2025
@tschellenbach tschellenbach marked this pull request as ready for review November 5, 2025 20:28
@tschellenbach tschellenbach merged commit b8e369f into main Nov 5, 2025
5 of 6 checks passed
@tschellenbach tschellenbach deleted the cursor/update-and-refactor-example-code-84d9 branch November 5, 2025 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants