class StreamedAgentResponse extends AgentResponse

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
StreamEvent> $events

Methods

withRawResponse(Response|null $response)

Set the raw HTTP response.

array
__serialize()

Prepare the instance for serialization, discarding the unserializable raw HTTP response.

__construct(string $invocationId, Collection $events, Meta $meta)

Build an agent response from its recorded stream events.

withMessages(Collection $messages)

Provide the message context for the response.

withToolCallsAndResults(Collection $toolCalls, Collection $toolResults)

Provide the tool calls and results for the message.

withReasoning(string $reasoning)

Provide the reasoning emitted across every step of the response.

withSteps(Collection $steps)

Provide the steps taken to generate the response.

withPendingApprovals(Collection $pendingApprovals)

Mark the response as waiting for tool approval.

bool
hasPendingApprovals()

Determine whether the response has tool calls pending approval.

string
__toString()

Get the string representation of the object.

static AgentResponse
fakeWithReasoning(string $reasoning, string $text = '')

Create a fake response that reasoned before answering.

static AgentResponse
fakeWithPendingApprovals(array|Collection $pendingApprovals)

Create a fake response that is waiting for approval.

withinConversation(string $conversationId, object|null $conversationUser = null)

Set the conversation UUID and participant for this response.

withStoredMessages(string|null $userMessageId, string|null $assistantMessageId)

Set the conversation message rows this turn wrote.

then(callable $callback)

Execute a callback with this response.

static string
joinReasoning(iterable $blocks)

Join reasoning blocks, separating each block with a blank line.

Details

in HasRawResponse at line 19
HasRawResponse withRawResponse(Response|null $response)

Set the raw HTTP response.

Parameters

Response|null $response

Return Value

HasRawResponse

in HasRawResponse at line 29
array __serialize()

Prepare the instance for serialization, discarding the unserializable raw HTTP response.

Return Value

array

at line 33
__construct(string $invocationId, Collection $events, Meta $meta)

Build an agent response from its recorded stream events.

Parameters

string $invocationId
Collection $events
Meta $meta

in TextResponse at line 58
TextResponse withMessages(Collection $messages)

Provide the message context for the response.

Parameters

Collection $messages

Return Value

TextResponse

in TextResponse at line 85
TextResponse withToolCallsAndResults(Collection $toolCalls, Collection $toolResults)

Provide the tool calls and results for the message.

Parameters

Collection $toolCalls
Collection $toolResults

Return Value

TextResponse

in TextResponse at line 100
TextResponse withReasoning(string $reasoning)

Provide the reasoning emitted across every step of the response.

Parameters

string $reasoning

Return Value

TextResponse

in TextResponse at line 112
TextResponse withSteps(Collection $steps)

Provide the steps taken to generate the response.

Parameters

Collection $steps

Return Value

TextResponse

in TextResponse at line 124
TextResponse withPendingApprovals(Collection $pendingApprovals)

Mark the response as waiting for tool approval.

Parameters

Collection $pendingApprovals

Return Value

TextResponse

in TextResponse at line 134
bool hasPendingApprovals()

Determine whether the response has tool calls pending approval.

Return Value

bool

in TextResponse at line 142
string __toString()

Get the string representation of the object.

Return Value

string

in AgentResponse at line 37
static AgentResponse fakeWithReasoning(string $reasoning, string $text = '')

Create a fake response that reasoned before answering.

Parameters

string $reasoning
string $text

Return Value

AgentResponse

in AgentResponse at line 49
static AgentResponse fakeWithPendingApprovals(array|Collection $pendingApprovals)

Create a fake response that is waiting for approval.

Parameters

array|Collection $pendingApprovals

Return Value

AgentResponse

in AgentResponse at line 58
AgentResponse withinConversation(string $conversationId, object|null $conversationUser = null)

Set the conversation UUID and participant for this response.

Parameters

string $conversationId
object|null $conversationUser

Return Value

AgentResponse

in AgentResponse at line 69
AgentResponse withStoredMessages(string|null $userMessageId, string|null $assistantMessageId)

Set the conversation message rows this turn wrote.

Parameters

string|null $userMessageId
string|null $assistantMessageId

Return Value

AgentResponse

in AgentResponse at line 80
AgentResponse then(callable $callback)

Execute a callback with this response.

Parameters

callable $callback

Return Value

AgentResponse

in JoinsReasoning at line 16
static protected string joinReasoning(iterable $blocks)

Join reasoning blocks, separating each block with a blank line.

Parameters

iterable $blocks

Return Value

string