Conversation
📝 WalkthroughWalkthroughEnsures agents are closed on warmup failure; EventManager gains stop() and is invoked during agent shutdown; many legacy event classes removed and exports reordered; runner switches to session-driven agent flow and adds a debug flag; TTS.close no longer emits PluginClosedEvent. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI
participant Launcher as Launcher
participant Session as Session
participant Agent as Agent
participant EventMgr as EventManager
participant DemoUI as DemoUI
CLI->>Launcher: warmup()
Launcher->>Agent: create()
Launcher->>Agent: warmup()
alt warmup succeeds
Launcher->>Session: start_session(call_id, call_type)
Session->>Agent: expose session.agent
CLI->>DemoUI: open if requested (session.agent)
Session->>Agent: session.wait()/operate
Agent->>EventMgr: events.stop() on _close
else warmup fails
Launcher->>Agent: finally -> close()
Agent->>EventMgr: events.stop()
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
agents-core/vision_agents/core/runner/runner.py (1)
168-202: Use environment variable or uvicorn config to enable asyncio debug mode, notset_debug()before loop creation.
asyncio.get_event_loop().set_debug(debug)called in a synchronous context before uvicorn starts is unreliable. The loop returned may not be the one uvicorn uses, and in newer Python versions this can raise when no loop is set. Per asyncio docs, enable debug mode viaPYTHONASYNCIODEBUG=1environment variable before the loop is created, or use uvicorn's loop selection (--loop asyncio) with the environment variable. Alternatively, set debug in a startup hook usingasyncio.get_running_loop()after the loop is running.🛠️ Environment variable approach (recommended)
+import os @@ - # Get the policy's loop and enable debug - asyncio.get_event_loop().set_debug(debug) + # Enable asyncio debug via environment variable before uvicorn creates its loop + if debug: + os.environ.setdefault("PYTHONASYNCIODEBUG", "1")
🤖 Fix all issues with AI agents
In `@agents-core/vision_agents/core/events/__init__.py`:
- Around line 56-64: The __all__ export list still includes
PluginInitializedEvent, PluginClosedEvent, and PluginErrorEvent even though they
are no longer imported from .base; update the module exports by either
re-introducing those classes in base.py and adding them to the import list in
__init__.py (so PluginInitializedEvent, PluginClosedEvent, PluginErrorEvent are
defined and imported), or remove those three symbols from the __all__ list in
__init__.py so it only exposes currently imported names like AudioFormat,
BaseEvent, ConnectionState, PluginBaseEvent, VideoProcessorDetectionEvent, and
EventManager.
In `@agents-core/vision_agents/core/events/manager.py`:
- Around line 185-188: The merge method calls em.stop() but does not wait for
the background processing task to finish, creating a race where em._queue can be
drained concurrently or the task may be pending/destroyed; change
EventManager.stop to cancel the processing Task and await its completion (or
return an awaitable that awaits the task), and update EventManager.merge to
await em.stop() (e.g., await em.stop()) before accessing or transferring
em._queue and other shared state so the background task is guaranteed to be
finished.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
agents-core/vision_agents/core/runner/runner.py (1)
175-203: Make--debugalways take effect.Using
os.environ.setdefaultmeans an existingPYTHONASYNCIODEBUG=0will bypass the flag. If a user passes--debug, it should force-enable the setting.🔧 Proposed change
- if debug: - os.environ.setdefault("PYTHONASYNCIODEBUG", "1") + if debug: + os.environ["PYTHONASYNCIODEBUG"] = "1"
🤖 Fix all issues with AI agents
In `@agents-core/vision_agents/core/runner/runner.py`:
- Around line 129-135: The comment is stale—this path no longer calls a separate
join_call function but always starts a session—so update the comment above the
logger.info and start_session calls to reflect a session-based flow;
specifically, change the mention of “join_call function” to something like
“start a session and join the call” near the logger.info(f"📞 Joining call:
{call_type}/{call_id}") and the self._launcher.start_session(...) invocation,
making it clear that session = await self._launcher.start_session(...) creates
the session and provides session.agent for the demo UI.
Summary by CodeRabbit
Bug Fixes
Behavior Changes
New Features
✏️ Tip: You can customize this high-level summary in your review settings.