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.



211
212
213
# File 'lib/claude_agent_sdk/types.rb', line 211

def content
  @content
end

#errorObject

Returns the value of attribute error.



211
212
213
# File 'lib/claude_agent_sdk/types.rb', line 211

def error
  @error
end

#message_idObject

Returns the value of attribute message_id.



211
212
213
# File 'lib/claude_agent_sdk/types.rb', line 211

def message_id
  @message_id
end

#modelObject

Returns the value of attribute model.



211
212
213
# File 'lib/claude_agent_sdk/types.rb', line 211

def model
  @model
end

#parent_tool_use_idObject

Returns the value of attribute parent_tool_use_id.



211
212
213
# File 'lib/claude_agent_sdk/types.rb', line 211

def parent_tool_use_id
  @parent_tool_use_id
end

#session_idObject

Returns the value of attribute session_id.



211
212
213
# File 'lib/claude_agent_sdk/types.rb', line 211

def session_id
  @session_id
end

#stop_reasonObject

Returns the value of attribute stop_reason.



211
212
213
# File 'lib/claude_agent_sdk/types.rb', line 211

def stop_reason
  @stop_reason
end

#usageObject

Returns the value of attribute usage.



211
212
213
# File 'lib/claude_agent_sdk/types.rb', line 211

def usage
  @usage
end

#uuidObject

Returns the value of attribute uuid.



211
212
213
# File 'lib/claude_agent_sdk/types.rb', line 211

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).



216
217
218
# File 'lib/claude_agent_sdk/types.rb', line 216

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