Entry method to run an agent via video/audio-based conversation. Args: parent_context: InvocationContext, the invocation context of the parent agent. Yields: Event: the events generated by the agent.
(
self,
parent_context: InvocationContext,
)
| 332 | |
| 333 | @final |
| 334 | async def run_live( |
| 335 | self, |
| 336 | parent_context: InvocationContext, |
| 337 | ) -> AsyncGenerator[Event, None]: |
| 338 | """Entry method to run an agent via video/audio-based conversation. |
| 339 | |
| 340 | Args: |
| 341 | parent_context: InvocationContext, the invocation context of the parent |
| 342 | agent. |
| 343 | |
| 344 | Yields: |
| 345 | Event: the events generated by the agent. |
| 346 | """ |
| 347 | |
| 348 | ctx = self._create_invocation_context(parent_context) |
| 349 | async with _instrumentation.record_agent_invocation(ctx, self): |
| 350 | if event := await self._handle_before_agent_callback(ctx): |
| 351 | yield event |
| 352 | if ctx.end_invocation: |
| 353 | return |
| 354 | |
| 355 | async with Aclosing(self._run_live_impl(ctx)) as agen: |
| 356 | async for event in agen: |
| 357 | yield event |
| 358 | |
| 359 | if event := await self._handle_after_agent_callback(ctx): |
| 360 | yield event |
| 361 | |
| 362 | async def _run_async_impl( |
| 363 | self, ctx: InvocationContext |
no test coverage detected