StructuredAgentResponse
class StructuredAgentResponse extends AgentResponse implements Arrayable, ArrayAccess, Jsonable, JsonSerializable
Traits
Properties
| Response|null | $raw | The raw HTTP response, if available for the provider. |
from HasRawResponse |
| Message> | $messages | from TextResponse | |
| ToolCall> | $toolCalls | from TextResponse | |
| ToolResult> | $toolResults | from TextResponse | |
| Step> | $steps | from TextResponse | |
| PendingApproval> | $pendingApprovals | from TextResponse | |
| string | $reasoning | from TextResponse | |
| string | $invocationId | from AgentResponse | |
| string|null | $conversationId | from AgentResponse | |
| object|null | $conversationUser | from AgentResponse | |
| string|null | $userMessageId | from AgentResponse | |
| string|null | $assistantMessageId | from AgentResponse | |
| array | $structured | from ProvidesStructuredResponse |
Methods
Prepare the instance for serialization, discarding the unserializable raw HTTP response.
Create a structured agent response.
Provide the tool calls and results for the message.
Provide the reasoning emitted across every step of the response.
Determine whether the response has tool calls pending approval.
Get the string representation of the object.
Create a fake response that reasoned before answering.
Create a fake response that is waiting for approval.
Set the conversation UUID and participant for this response.
Set the conversation message rows this turn wrote.
Determine if an item exists at an offset.
Set the item at a given offset.
Get the instance as an array.
Convert the object to its JSON representation.
Get the JSON serializable representation of the instance.
Details
in
HasRawResponse at line 19
HasRawResponse
withRawResponse(Response|null $response)
Set the raw HTTP response.
in
HasRawResponse at line 29
array
__serialize()
Prepare the instance for serialization, discarding the unserializable raw HTTP response.
at line 24
__construct(string $invocationId, array $structured, string $text, TextUsage $usage, Meta $meta)
Create a structured agent response.
in
TextResponse at line 58
TextResponse
withMessages(Collection $messages)
Provide the message context for the response.
in
TextResponse at line 85
TextResponse
withToolCallsAndResults(Collection $toolCalls, Collection $toolResults)
Provide the tool calls and results for the message.
in
TextResponse at line 100
TextResponse
withReasoning(string $reasoning)
Provide the reasoning emitted across every step of the response.
in
TextResponse at line 112
TextResponse
withSteps(Collection $steps)
Provide the steps taken to generate the response.
in
TextResponse at line 124
TextResponse
withPendingApprovals(Collection $pendingApprovals)
Mark the response as waiting for tool approval.
in
TextResponse at line 134
bool
hasPendingApprovals()
Determine whether the response has tool calls pending approval.
at line 62
string
__toString()
Get the string representation of the object.
in
AgentResponse at line 37
static AgentResponse
fakeWithReasoning(string $reasoning, string $text = '')
Create a fake response that reasoned before answering.
in
AgentResponse at line 49
static AgentResponse
fakeWithPendingApprovals(array|Collection $pendingApprovals)
Create a fake response that is waiting for approval.
in
AgentResponse at line 58
AgentResponse
withinConversation(string $conversationId, object|null $conversationUser = null)
Set the conversation UUID and participant for this response.
in
AgentResponse at line 69
AgentResponse
withStoredMessages(string|null $userMessageId, string|null $assistantMessageId)
Set the conversation message rows this turn wrote.
in
AgentResponse at line 80
AgentResponse
then(callable $callback)
Execute a callback with this response.
in
ProvidesStructuredResponse at line 14
bool
offsetExists(mixed $offset)
Determine if an item exists at an offset.
in
ProvidesStructuredResponse at line 22
mixed
offsetGet(mixed $offset)
Get an item at a given offset.
in
ProvidesStructuredResponse at line 30
void
offsetSet(mixed $offset, mixed $value)
Set the item at a given offset.
in
ProvidesStructuredResponse at line 42
void
offsetUnset(mixed $offset)
Unset the item at a given offset.
at line 36
array
toArray()
Get the instance as an array.
at line 46
string
toJson(int $options = 0)
Convert the object to its JSON representation.
at line 54
array
jsonSerialize()
Get the JSON serializable representation of the instance.