AgentResponse Class
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.
Represents the response to an AIAgent run request, containing messages and metadata about the interaction.
public class AgentResponse
type AgentResponse = class
Public Class AgentResponse
- Inheritance
-
AgentResponse
- Derived
Remarks
AgentResponse provides one or more response messages and metadata about the response. A typical response will contain a single message, however a response may contain multiple messages in a variety of scenarios. For example, if the agent internally invokes functions or tools, performs RAG retrievals or has other complex logic, a single run by the agent may produce many messages showing the intermediate progress that the agent made towards producing the agent result.
To get the text result of the response, use the Text property or simply call ToString() on the AgentResponse.
Constructors
| Name | Description |
|---|---|
| AgentResponse() |
Initializes a new instance of the AgentResponse class. |
| AgentResponse(AgentResponse) |
Initializes a new instance of the AgentResponse class from an existing AgentResponse. |
| AgentResponse(ChatMessage) |
Initializes a new instance of the AgentResponse class. |
| AgentResponse(ChatResponse) |
Initializes a new instance of the AgentResponse class from an existing ChatResponse. |
| AgentResponse(IList<ChatMessage>) |
Initializes a new instance of the AgentResponse class with the specified collection of messages. |
Properties
| Name | Description |
|---|---|
| AdditionalProperties |
Gets or sets additional properties associated with this response. |
| AgentId |
Gets or sets the identifier of the agent that generated this response. |
| ContinuationToken |
Gets or sets the continuation token for getting the result of a background agent response. |
| CreatedAt |
Gets or sets the timestamp indicating when this response was created. |
| Messages |
Gets or sets the collection of messages to be represented by this response. |
| RawRepresentation |
Gets or sets the raw representation of the run response from an underlying implementation. |
| ResponseId |
Gets or sets the unique identifier for this specific response. |
| Text |
Gets the concatenated text content of all messages in this response. |
| Usage |
Gets or sets the resource usage information for generating this response. |
Methods
| Name | Description |
|---|---|
| ToAgentResponseUpdates() |
Converts this AgentResponse into a collection of AgentResponseUpdate instances suitable for streaming scenarios. |
| ToString() | Returns a string that represents the current object. |
Extension Methods
| Name | Description |
|---|---|
| AsChatResponse(AgentResponse) |
Creates a ChatResponse from an AgentResponse instance. |
| AsOpenAIChatCompletion(AgentResponse) |
Creates or extracts a native OpenAI OpenAI.Chat.ChatCompletion object from an AgentResponse. |
| AsOpenAIResponse(AgentResponse) |
Creates or extracts a native OpenAI OpenAI.Responses.ResponseResult object from an AgentResponse. |