Contains the result of an agent task execution, including the final response,
conversation history, cost information, and all events that occurred during
execution.
Public fields
response
The final text response from the agent
turns
List of conversation turns
cost
Cost information (list with input, output, cached, total)
events
List of all AgentEvent objects from execution
duration
Execution duration in seconds
stop_reason
Reason the agent stopped
Methods
Method new()
Create a new AgentResult object.
Usage
AgentResult$new(
response = NULL,
turns = list(),
cost = list(input = 0, output = 0, cached = 0, total = 0),
events = list(),
duration = NULL,
stop_reason = "complete"
)
Arguments
response
Final text response
turns
List of conversation turns
cost
Cost information
events
List of AgentEvent objects
duration
Execution duration in seconds
stop_reason
Reason for stopping
Returns
A new AgentResult object
Method n_turns()
Get the number of turns in the conversation.
Returns
Integer count of turns
Get all tool calls made during execution.
Returns
List of tool_start events
Method text_chunks()
Get all text chunks from the response.
Usage
AgentResult$text_chunks()
Returns
Character vector of text chunks
Method is_success()
Check if the agent completed successfully.
Returns
Logical indicating success
Print the result summary.
Method clone()
The objects of this class are cloneable with this method.
Usage
AgentResult$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.