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_idStable session identifier for run correlation
run_idUnique identifier shared by events from this run
agent_idImmutable identifier for the Agent instance
agent_nameOptional human-readable Agent name
parent_agent_idParent Agent identifier for delegated runs
parent_run_idParent run identifier for delegated runs
delegation_idDelegation identifier for delegated runs
usageRun-scoped AgentUsage
Methods
AgentResult$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,
run_id = NULL,
usage = AgentUsage(),
agent_id = NULL,
agent_name = NULL,
parent_agent_id = NULL,
parent_run_id = NULL,
delegation_id = NULL,
run_context = list()
)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_idStable session identifier (if any)
run_idUnique run identifier (if any)
usageRun-scoped AgentUsage
agent_idAgent instance identifier (if any)
agent_nameOptional human-readable Agent name
parent_agent_idParent Agent identifier for delegated runs
parent_run_idParent run identifier for delegated runs
delegation_idDelegation identifier for delegated runs
run_contextImmutable product context for this run