NAME

Claude::Agent::Message::Assistant - Assistant message type

DESCRIPTION

Represents an assistant (Claude) message in the conversation.

ATTRIBUTES

type

Always assistant.

message

HashRef with role, content (an array of content blocks) and, from the API, id, model, stop_reason and usage.

model

The model that generated this response.

error

Set when the CLI reports an API error for this message.

uuid, session_id, parent_tool_use_id, agent_id, raw

See Claude::Agent::Message::Base.

METHODS

new

Takes a flat list of name/value pairs. Unknown names are ignored.

content_blocks

my $blocks = $msg->content_blocks;

Returns an ArrayRef of content block objects (see Claude::Agent::Content). The objects are built once and shared between calls: mutating one affects every holder of a reference to it. Copy with "dclone" in Storable before modifying a block in place.

text

my $text = $msg->text;

The text of every text block, joined with newlines.

tool_uses

my $uses = $msg->tool_uses;

ArrayRef of the tool_use blocks.

usage

The API usage hash for this message, if present.

stop_reason

The API stop reason for this message, if present.

message_id

The API message id, if present.

AUTHOR

LNATION, <email at lnation.org>

LICENSE

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under The Artistic License 2.0 (GPL Compatible).