MCPcopy Index your code
hub / github.com/google/adk-python / run_node_scenario

Function run_node_scenario

tests/unittests/telemetry/functional_test_helpers.py:408–436  ·  view source on GitHub ↗

Runs the workflow scenario to completion, draining the event stream. If ``event_sink`` is provided, collected events are appended to it as they are drained. This lets callers inspect the events that were emitted before an exception propagates (e.g. when ``failing=True``).

(
    *, failing: bool = False, event_sink: list[Event] | None = None
)

Source from the content-addressed store, hash-verified

406
407
408async def run_node_scenario(
409 *, failing: bool = False, event_sink: list[Event] | None = None
410) -> list[Event]:
411 """Runs the workflow scenario to completion, draining the event stream.
412
413 If ``event_sink`` is provided, collected events are appended to it as they
414 are drained. This lets callers inspect the events that were emitted before
415 an exception propagates (e.g. when ``failing=True``).
416 """
417 workflow = build_test_workflow(failing=failing)
418 runner = InMemoryRunner(app_name=NODE_APP_NAME, node=workflow)
419 session = await runner.session_service.create_session(
420 app_name=NODE_APP_NAME, user_id=NODE_USER_ID
421 )
422 content = Content(parts=[Part.from_text(text=USER_PROMPT)], role="user")
423
424 collected_events: list[Event] = event_sink if event_sink is not None else []
425
426 async with aclosing(
427 runner.run_async(
428 user_id=NODE_USER_ID,
429 session_id=session.id,
430 new_message=content,
431 )
432 ) as agen:
433 async for event in agen:
434 collected_events.append(event)
435
436 return collected_events
437
438
439async def run_agent_scenario(runner: TestInMemoryRunner) -> None:

Calls 5

run_asyncMethod · 0.95
InMemoryRunnerClass · 0.90
build_test_workflowFunction · 0.85
create_sessionMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected