class StoredMessage implements Arrayable, JsonSerializable

A conversation message as it was persisted, with its JSON columns decoded.

Message is what the model sees; this is what was stored, and it keeps the identity and timestamps a rendered transcript needs.

Methods

__construct(string $id, string $role, string $content, CarbonInterface|null $createdAt = null, array $usage = [], array $meta = [], array $steps = [], MessageStatus $status = MessageStatus::Completed, array $attachments = [])

Create a stored conversation message.

static StoredMessage
fromArray(array $record)

Reconstruct an instance from a stored row, decoding its JSON columns.

array
toArray()

Get the instance as an array, in the shape it was stored in.

array
jsonSerialize()

Get the JSON serializable representation of the message.

array
toolCalls()

The tool calls made across every step of the turn, in step order.

array
providerToolCalls()

The provider-hosted tool calls made across every step of the turn, in step order.

array
toolResults()

The tool results recorded across every step of the turn, in step order.

static array
decoded(mixed $value)

Decode a JSON column, tolerating null and malformed values.

Details

at line 30
__construct(string $id, string $role, string $content, CarbonInterface|null $createdAt = null, array $usage = [], array $meta = [], array $steps = [], MessageStatus $status = MessageStatus::Completed, array $attachments = [])

Create a stored conversation message.

Parameters

string $id
string $role
string $content
CarbonInterface|null $createdAt
array $usage
array $meta
array $steps
MessageStatus $status
array $attachments

at line 48
static StoredMessage fromArray(array $record)

Reconstruct an instance from a stored row, decoding its JSON columns.

Parameters

array $record

Return Value

StoredMessage

at line 68
array toArray()

Get the instance as an array, in the shape it was stored in.

Return Value

array

at line 88
array jsonSerialize()

Get the JSON serializable representation of the message.

Return Value

array

at line 98
array toolCalls()

The tool calls made across every step of the turn, in step order.

Return Value

array

at line 108
array providerToolCalls()

The provider-hosted tool calls made across every step of the turn, in step order.

Return Value

array

at line 118
array toolResults()

The tool results recorded across every step of the turn, in step order.

Return Value

array

at line 131
static protected array decoded(mixed $value)

Decode a JSON column, tolerating null and malformed values.

Parameters

mixed $value

Return Value

array