Class: ToolCallDecorator

Inherits:
EventDecorator show all
Defined in:
app/decorators/tool_call_decorator.rb

Overview

Decorates tool_call events for display in the TUI. Hidden in basic mode — tool activity is represented by the aggregated tool counter instead. Verbose mode returns tool name and a formatted preview of the input arguments. Debug mode shows full untruncated input as pretty-printed JSON with tool_use_id.

Think tool calls are special: “aloud” thoughts are shown in all view modes (with a thought bubble), while “inner” thoughts are visible only in verbose and debug modes.

Constant Summary collapse

THINK_TOOL =
"think"

Constants inherited from EventDecorator

EventDecorator::ERROR_ICON, EventDecorator::MIDDLE_TRUNCATION_MARKER, EventDecorator::RETURN_ARROW, EventDecorator::TOOL_ICON

Instance Method Summary collapse

Methods inherited from EventDecorator

for, #render

Instance Method Details

#render_basicHash?

In basic mode, only “aloud” think calls are visible. All other tool calls are hidden (represented by the tool counter).

Returns:

  • (Hash, nil)

    structured think data for aloud thoughts, nil otherwise



19
20
21
22
23
24
# File 'app/decorators/tool_call_decorator.rb', line 19

def render_basic
  return unless think?
  return unless aloud?

  {role: :think, content: thoughts, visibility: "aloud"}
end

#render_brainString

Think calls get full text — the agent’s reasoning IS the signal. Other tool calls show tool name + params (compact JSON).

Returns:

  • (String)

    transcript line for the analytical brain



51
52
53
54
55
56
57
# File 'app/decorators/tool_call_decorator.rb', line 51

def render_brain
  if think?
    "Think: #{thoughts}"
  else
    "Tool call: #{payload["tool_name"]}(#{tool_input.to_json})"
  end
end

#render_debugHash

Returns full tool call data with untruncated input and tool_use_id ‘:tool_call, tool: String, input: String, tool_use_id: String|nil, timestamp: Integer|nil`.

Returns:

  • (Hash)

    full tool call data with untruncated input and tool_use_id ‘:tool_call, tool: String, input: String, tool_use_id: String|nil, timestamp: Integer|nil`



36
37
38
39
40
41
42
43
44
45
46
# File 'app/decorators/tool_call_decorator.rb', line 36

def render_debug
  return render_think_debug if think?

  {
    role: :tool_call,
    tool: payload["tool_name"],
    input: JSON.pretty_generate(payload["tool_input"] || {}),
    tool_use_id: payload["tool_use_id"],
    timestamp: timestamp
  }
end

#render_verboseHash

Returns structured tool call data ‘:tool_call, tool: String, input: String, timestamp: Integer|nil`.

Returns:

  • (Hash)

    structured tool call data ‘:tool_call, tool: String, input: String, timestamp: Integer|nil`



28
29
30
31
32
# File 'app/decorators/tool_call_decorator.rb', line 28

def render_verbose
  return render_think_verbose if think?

  {role: :tool_call, tool: payload["tool_name"], input: format_input, timestamp: timestamp}
end