NAME
Claude::Agent::Message::Assistant - Assistant message type
DESCRIPTION
Represents an assistant (Claude) message in the conversation.
ATTRIBUTES
type - Always 'assistant'
uuid - Unique message identifier
session_id - Session identifier
message - HashRef with 'role' and 'content' (array of content blocks)
model - The model that generated this response
parent_tool_use_id - Optional, set if message is within a subagent
METHODS
content_blocks
my $blocks = $msg->content_blocks;
Returns arrayref of content blocks from the message.
Note: Results are cached on first access. If the underlying message content is modified after this method is called, the cached value will be returned on subsequent calls. Messages are typically immutable after creation.
Warning - Shared Object References: The returned arrayref is a shallow copy, but the Content objects inside are shared with the internal cache. This means:
Mutating a Content object affects ALL code holding references to it
Subsequent calls to content_blocks() return the same (mutated) objects
This can cause subtle bugs if Content objects are modified in place
Recommended: Treat returned Content objects as read-only. If you need to modify content, create deep copies of the objects first using appropriate cloning methods.
text
my $text = $msg->text;
Returns concatenated text content from all text blocks.
tool_uses
my $uses = $msg->tool_uses;
Returns arrayref of tool_use blocks.
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).