Result object returned by model generation.
Details
This class uses lock_objects = FALSE to allow dynamic field addition.
This enables the ReAct loop and other components to attach additional
metadata (like steps, all_tool_calls) without modifying the class.
For models that support reasoning/thinking (like OpenAI o1/o3, DeepSeek, Claude with extended thinking),
the reasoning field contains the model's chain-of-thought content.
For Responses API models, response_id contains the server-side response ID
which can be used for multi-turn conversations without sending full history.
Public fields
textThe generated text content.
usageToken usage information (list with prompt_tokens, completion_tokens, total_tokens).
finish_reasonReason the model stopped generating.
warningsAny warnings from the model.
raw_responseThe raw response from the API.
tool_callsList of tool calls requested by the model. Each item contains id, name, arguments.
stepsNumber of ReAct loop steps taken (when max_steps > 1).
all_tool_callsAccumulated list of all tool calls made across all ReAct steps.
reasoningChain-of-thought/reasoning content from models that support it (o1, o3, DeepSeek, etc.).
response_idServer-side response ID for Responses API (used for stateful multi-turn conversations).
Methods
Method new()
Initialize a GenerateResult object.
Usage
GenerateResult$new(
text = NULL,
usage = NULL,
finish_reason = NULL,
warnings = NULL,
raw_response = NULL,
tool_calls = NULL,
steps = NULL,
all_tool_calls = NULL,
reasoning = NULL,
response_id = NULL
)Arguments
textGenerated text.
usageToken usage.
finish_reasonReason for stopping.
warningsWarnings.
raw_responseRaw API response.
tool_callsTool calls requested by the model.
stepsNumber of ReAct steps taken.
all_tool_callsAll tool calls across steps.
reasoningChain-of-thought content.
response_idServer-side response ID for Responses API.