ChatClientAgent.RunStreamingAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| RunStreamingAsync(String, AgentSession, ChatClientAgentRunOptions, CancellationToken) |
Runs the agent in streaming mode with a text message from the user. |
| RunStreamingAsync(AgentSession, ChatClientAgentRunOptions, CancellationToken) |
Runs the agent in streaming mode without providing new input messages, relying on existing context and instructions. |
| RunStreamingAsync(ChatMessage, AgentSession, ChatClientAgentRunOptions, CancellationToken) |
Runs the agent in streaming mode with a single chat message. |
| RunStreamingAsync(IEnumerable<ChatMessage>, AgentSession, ChatClientAgentRunOptions, CancellationToken) |
Runs the agent in streaming mode with a collection of chat messages. |
RunStreamingAsync(String, AgentSession, ChatClientAgentRunOptions, CancellationToken)
Runs the agent in streaming mode with a text message from the user.
public System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.AgentResponseUpdate> RunStreamingAsync(string message, Microsoft.Agents.AI.AgentSession? session, Microsoft.Agents.AI.ChatClientAgentRunOptions? options, System.Threading.CancellationToken cancellationToken = default);
override this.RunStreamingAsync : string * Microsoft.Agents.AI.AgentSession * Microsoft.Agents.AI.ChatClientAgentRunOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.AgentResponseUpdate>
Public Function RunStreamingAsync (message As String, session As AgentSession, options As ChatClientAgentRunOptions, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of AgentResponseUpdate)
Parameters
- message
- String
The user message to send to the agent.
- 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 message and any response messages generated during invocation.
- options
- ChatClientAgentRunOptions
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.
Applies to
RunStreamingAsync(AgentSession, ChatClientAgentRunOptions, CancellationToken)
Runs the agent in streaming mode without providing new input messages, relying on existing context and instructions.
public System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.AgentResponseUpdate> RunStreamingAsync(Microsoft.Agents.AI.AgentSession? session, Microsoft.Agents.AI.ChatClientAgentRunOptions? options, System.Threading.CancellationToken cancellationToken = default);
override this.RunStreamingAsync : Microsoft.Agents.AI.AgentSession * Microsoft.Agents.AI.ChatClientAgentRunOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.AgentResponseUpdate>
Public Function RunStreamingAsync (session As AgentSession, options As ChatClientAgentRunOptions, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of AgentResponseUpdate)
Parameters
- session
- AgentSession
The conversation session to use for this invocation. If null, a new session will be created.
The session will be updated with any response messages generated during invocation.
- options
- ChatClientAgentRunOptions
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.
Applies to
RunStreamingAsync(ChatMessage, AgentSession, ChatClientAgentRunOptions, CancellationToken)
Runs the agent in streaming mode with a single chat message.
public System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.AgentResponseUpdate> RunStreamingAsync(Microsoft.Extensions.AI.ChatMessage message, Microsoft.Agents.AI.AgentSession? session, Microsoft.Agents.AI.ChatClientAgentRunOptions? options, System.Threading.CancellationToken cancellationToken = default);
override this.RunStreamingAsync : Microsoft.Extensions.AI.ChatMessage * Microsoft.Agents.AI.AgentSession * Microsoft.Agents.AI.ChatClientAgentRunOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.AgentResponseUpdate>
Public Function RunStreamingAsync (message As ChatMessage, session As AgentSession, options As ChatClientAgentRunOptions, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of AgentResponseUpdate)
Parameters
- message
- ChatMessage
The chat message to send to the agent.
- 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 message and any response messages generated during invocation.
- options
- ChatClientAgentRunOptions
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.
Applies to
RunStreamingAsync(IEnumerable<ChatMessage>, AgentSession, ChatClientAgentRunOptions, CancellationToken)
Runs the agent in streaming mode with a collection of chat messages.
public System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.AgentResponseUpdate> RunStreamingAsync(System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages, Microsoft.Agents.AI.AgentSession? session, Microsoft.Agents.AI.ChatClientAgentRunOptions? options, System.Threading.CancellationToken cancellationToken = default);
override this.RunStreamingAsync : seq<Microsoft.Extensions.AI.ChatMessage> * Microsoft.Agents.AI.AgentSession * Microsoft.Agents.AI.ChatClientAgentRunOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.AgentResponseUpdate>
Public Function RunStreamingAsync (messages As IEnumerable(Of ChatMessage), session As AgentSession, options As ChatClientAgentRunOptions, 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
- ChatClientAgentRunOptions
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.