Class: ClaudeAgentSDK::AssistantMessage

Inherits:
Type
  • Object
show all
Defined in:
lib/claude_agent_sdk/types.rb

Overview

Assistant message with content blocks

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#[], #[]=, from_hash, #initialize, #to_h, wrap

Constructor Details

This class inherits a constructor from ClaudeAgentSDK::Type

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ClaudeAgentSDK::Type

Instance Attribute Details

#contentObject

Returns the value of attribute content.



231
232
233
# File 'lib/claude_agent_sdk/types.rb', line 231

def content
  @content
end

#errorObject

Returns the value of attribute error.



231
232
233
# File 'lib/claude_agent_sdk/types.rb', line 231

def error
  @error
end

#message_idObject

Returns the value of attribute message_id.



231
232
233
# File 'lib/claude_agent_sdk/types.rb', line 231

def message_id
  @message_id
end

#modelObject

Returns the value of attribute model.



231
232
233
# File 'lib/claude_agent_sdk/types.rb', line 231

def model
  @model
end

#parent_tool_use_idObject

Returns the value of attribute parent_tool_use_id.



231
232
233
# File 'lib/claude_agent_sdk/types.rb', line 231

def parent_tool_use_id
  @parent_tool_use_id
end

#session_idObject

Returns the value of attribute session_id.



231
232
233
# File 'lib/claude_agent_sdk/types.rb', line 231

def session_id
  @session_id
end

#stop_reasonObject

Returns the value of attribute stop_reason.



231
232
233
# File 'lib/claude_agent_sdk/types.rb', line 231

def stop_reason
  @stop_reason
end

#usageObject

Returns the value of attribute usage.



231
232
233
# File 'lib/claude_agent_sdk/types.rb', line 231

def usage
  @usage
end

#uuidObject

Returns the value of attribute uuid.



231
232
233
# File 'lib/claude_agent_sdk/types.rb', line 231

def uuid
  @uuid
end

Instance Method Details

#textObject Also known as: to_s

Concatenated text across every TextBlock in this message’s content. Returns “” when the message has no text (e.g., a pure tool_use turn).



236
237
238
# File 'lib/claude_agent_sdk/types.rb', line 236

def text
  Array(content).grep(TextBlock).map(&:text).join("\n\n")
end