ChatResponseUpdate
Models & Types · AiDotNet.Agentic.Models
A single incremental update in a streaming chat response.
For Beginners
This is one “frame” of the model typing in real time. Each frame usually
holds the next little bit of text (TextDelta). The last frame tells you it finished
and how many tokens were used. Use the factory methods (ForText, ForToolCall,
ForFinish) to build updates without juggling many constructor arguments.
How It Works
Streaming delivers a response as a sequence of these updates instead of one final object. A typical
stream carries the role once, then many TextDelta chunks (and/or
ToolCall fragments), and finally a FinishReason with optional
Usage. Concatenating the deltas reconstructs the full reply.
Constructors
| Constructor | Summary |
|---|---|
ChatResponseUpdate(ChatRole? role, string textDelta, StreamingToolCallUpdate toolCall, ChatFinishReason? finishReason, ChatUsage usage) |
Initializes a new streaming update. |
Properties
| Property | Summary |
|---|---|
ChatFinishReason? FinishReason { get; } |
Gets the finish reason, present only on the terminal update. |
ChatRole? Role { get; } |
Gets the author role for the response, when carried by this update. |
ChatUsage Usage { get; } |
Gets token usage, present only on the terminal update for providers that report it mid-stream. |
StreamingToolCallUpdate ToolCall { get; } |
Gets a streaming tool-call fragment, or null when this update carries none. |
string TextDelta { get; } |
Gets the next fragment of assistant text, or null when this update carries none. |
Methods
| Method | Summary |
|---|---|
ChatResponseUpdate ForFinish(ChatFinishReason finishReason, ChatUsage usage) |
Creates the terminal update carrying the finish reason and optional usage. |
ChatResponseUpdate ForText(string textDelta) |
Creates an update carrying a fragment of assistant text. |
ChatResponseUpdate ForToolCall(StreamingToolCallUpdate toolCall) |
Creates an update carrying a streaming tool-call fragment. |