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
responseThe final text response from the agent
turnsList of conversation turns
costCost information (list with input, output, cached, total)
eventsList of all AgentEvent objects from execution
durationExecution duration in seconds
stop_reasonReason the agent stopped
structured_outputParsed/validated structured output (if requested)
session_idCompat session identifier when Claude SDK mode is active
snapshot_pathLatest compat snapshot path when session persistence is active
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",
structured_output = NULL,
session_id = NULL,
snapshot_path = NULL
)Arguments
responseFinal text response
turnsList of conversation turns
costCost information
eventsList of AgentEvent objects
durationExecution duration in seconds
stop_reasonReason for stopping
structured_outputParsed structured output (if any)
session_idCompat session identifier (if any)
snapshot_pathLatest compat snapshot path (if any)