sendStream method

AgentTurn<State> sendStream({
  1. String? text,
  2. Message? message,
  3. List<ToolResponsePart>? respond,
  4. List<ToolRequestPart>? restart,
  5. CancellationToken? cancel,
  6. Map<String, dynamic>? context,
})

Runs a single turn and returns an AgentTurn exposing .stream and .response.

Pass either text (free-form user text) or a fully-built message (at most one). To resume an interrupted turn in the same call, pass respond entries (built via AgentInterrupt.respond) and/or restart entries (built via AgentInterrupt.restart); they are bundled into an AgentResume internally.

context is the ambient request context to run the turn under. It is only honored by the in-process transport (observable as AgentFnOptions.context); the remote transport rejects a non-empty context with an UnsupportedError (see AgentTransport).

Implementation

AgentTurn<State> sendStream({
  String? text,
  Message? message,
  List<ToolResponsePart>? respond,
  List<ToolRequestPart>? restart,
  CancellationToken? cancel,
  Map<String, dynamic>? context,
}) => _sendStream(
  _buildAgentInput(
    text: text,
    message: message,
    respond: respond,
    restart: restart,
  ),
  cancel: cancel,
  context: context,
);