Share via


AIAgent.RunCoreStreamingAsync Method

Definition

Core implementation of the agent streaming invocation logic with a collection of chat messages.

protected abstract System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.AgentResponseUpdate> RunCoreStreamingAsync(System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages, Microsoft.Agents.AI.AgentSession? session = default, Microsoft.Agents.AI.AgentRunOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member RunCoreStreamingAsync : seq<Microsoft.Extensions.AI.ChatMessage> * Microsoft.Agents.AI.AgentSession * Microsoft.Agents.AI.AgentRunOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.AgentResponseUpdate>
Protected MustOverride Function RunCoreStreamingAsync (messages As IEnumerable(Of ChatMessage), Optional session As AgentSession = Nothing, Optional options As AgentRunOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of AgentResponseUpdate)

Parameters

messages
IEnumerable<ChatMessage>

The collection of messages to send to the agent for processing.

session
AgentSession

The conversation session to use for this invocation. If null, a new session will be created. The session will be updated with the input messages and any response updates generated during invocation.

options
AgentRunOptions

Optional configuration parameters for controlling the agent's invocation behavior.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

An asynchronous enumerable of AgentResponseUpdate instances representing the streaming response.

Remarks

This is the primary streaming invocation method that implementations must override. It provides real-time updates as the agent processes the input and generates its response, enabling more responsive user experiences.

Each AgentResponseUpdate represents a portion of the complete response, allowing consumers to display partial results, implement progressive loading, or provide immediate feedback to users.

Applies to