run method

  1. @override
Stream<Map<String, Object?>> run(
  1. Map<String, Object?> input
)
override

Posts input, the body of one AG-UI run, and streams the events of the run as decoded JSON.

TEXT_MESSAGE_CHUNK and TOOL_CALL_CHUNK come as the content, start and args events they abbreviate, each sender, parent or subagent, continuing its own open message or call. A chunk without an id that several subagents could own fails the stream with a FormatException.

Replayed runs before the requested runId and threadId are skipped. The stream ends right after its RUN_FINISHED or RUN_ERROR, and the connection closes with it. A stream that ends earlier, or fails, means the run broke. Cancelling the subscription aborts the request, even while it waits for the response headers, and its future completes once the connection is cleaned up.

The session cancels only when it is disposed, when the stream fails, or when an event fails the run. Stopping a run does not cancel it: ADK keeps running, and the thread stays consistent only if the run's events are read to the end.

Implementation

@override
Stream<Map<String, Object?>> run(Map<String, Object?> input) {
  _requests.add(input);
  return _play(_requests.length - 1, input);
}