|
39 | 39 | from ..vad.events import VADAudioEvent |
40 | 40 | from . import events |
41 | 41 | from .conversation import Conversation |
| 42 | +from ..profiling import Profiler |
42 | 43 |
|
43 | 44 | if TYPE_CHECKING: |
44 | 45 | from vision_agents.plugins.getstream.stream_edge_transport import StreamEdge |
@@ -103,6 +104,7 @@ def __init__( |
103 | 104 | # MCP servers for external tool and resource access |
104 | 105 | mcp_servers: Optional[List[MCPBaseServer]] = None, |
105 | 106 | tracer: Tracer = trace.get_tracer("agents"), |
| 107 | + profiler: Optional[Profiler] = None, |
106 | 108 | ): |
107 | 109 | self.instructions = instructions |
108 | 110 | self.edge = edge |
@@ -146,7 +148,7 @@ def __init__( |
146 | 148 | self._pending_user_transcripts: Dict[str, str] = {} |
147 | 149 |
|
148 | 150 | # Merge plugin events BEFORE subscribing to any events |
149 | | - for plugin in [stt, tts, turn_detection, vad, llm, edge]: |
| 151 | + for plugin in [stt, tts, turn_detection, vad, llm, edge, profiler]: |
150 | 152 | if plugin and hasattr(plugin, "events"): |
151 | 153 | self.logger.info(f"Registered plugin {plugin}") |
152 | 154 | self.events.merge(plugin.events) |
@@ -177,6 +179,8 @@ def __init__( |
177 | 179 | self._setup_stt() |
178 | 180 | self._setup_turn_detection() |
179 | 181 |
|
| 182 | + self.events.send(events.AgentInitEvent()) |
| 183 | + |
180 | 184 | async def simple_response( |
181 | 185 | self, text: str, participant: Optional[Participant] = None |
182 | 186 | ) -> None: |
@@ -441,6 +445,8 @@ async def on_ended(event: CallEndedEvent): |
441 | 445 | except asyncio.CancelledError: |
442 | 446 | running_event.clear() |
443 | 447 |
|
| 448 | + self.events.send(events.AgentFinishEvent()) |
| 449 | + |
444 | 450 | await asyncio.shield(self.close()) |
445 | 451 |
|
446 | 452 | async def close(self): |
|
0 commit comments