Class: Roast::Cogs::Agent::Providers::Claude::ToolResult

Inherits:
Object
  • Object
show all
Defined in:
lib/roast/cogs/agent/providers/claude/tool_result.rb

Constant Summary collapse

TRUNCATE_LIMIT =
45

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tool_use:, content:, is_error:) ⇒ ToolResult

: (tool_use: Messages::ToolUseMessage?, content: (String | Array[Hash[Symbol, untyped]])?, is_error: bool) -> void



26
27
28
29
30
31
32
# File 'lib/roast/cogs/agent/providers/claude/tool_result.rb', line 26

def initialize(tool_use:, content:, is_error:)
  @tool_name = tool_use&.name || :unknown
  @tool_use_input = tool_use&.input || {} #: Hash[Symbol, untyped]
  @tool_use_description = @tool_use_input[:description] #: String?
  @content = content
  @is_error = is_error
end

Instance Attribute Details

#contentObject (readonly)

: (String | Array[Hash[Symbol, untyped]])?



20
21
22
# File 'lib/roast/cogs/agent/providers/claude/tool_result.rb', line 20

def content
  @content
end

#is_errorObject (readonly)

: bool



23
24
25
# File 'lib/roast/cogs/agent/providers/claude/tool_result.rb', line 23

def is_error
  @is_error
end

#tool_nameObject (readonly)

: Symbol?



11
12
13
# File 'lib/roast/cogs/agent/providers/claude/tool_result.rb', line 11

def tool_name
  @tool_name
end

#tool_use_descriptionObject (readonly)

: String?



17
18
19
# File 'lib/roast/cogs/agent/providers/claude/tool_result.rb', line 17

def tool_use_description
  @tool_use_description
end

#tool_use_inputObject (readonly)

: Hash[Symbol, untyped]



14
15
16
# File 'lib/roast/cogs/agent/providers/claude/tool_result.rb', line 14

def tool_use_input
  @tool_use_input
end

Instance Method Details

#formatObject

: () -> String



35
36
37
38
39
40
41
42
# File 'lib/roast/cogs/agent/providers/claude/tool_result.rb', line 35

def format
  return error_line if is_error

  format_method_name = "format_#{tool_name}".to_sym
  return send(format_method_name) if respond_to?(format_method_name, true)

  format_unknown
end