Class: ToolResponseDecorator

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

Overview

Decorates tool_response events for display in the TUI. Hidden in basic mode — tool activity is represented by the aggregated tool counter instead. Verbose mode returns truncated output with a success/failure indicator and tool name for per-tool client-side rendering. Debug mode shows full untruncated output with tool_use_id and estimated token count.

Think tool responses (“OK”) are hidden in basic and verbose modes because the value is in the tool_call (the thoughts), not the response.

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_basicnil

Returns tool responses are hidden in basic mode.

Returns:

  • (nil)

    tool responses are hidden in basic mode



16
17
18
# File 'app/decorators/tool_response_decorator.rb', line 16

def render_basic
  nil
end

#render_brainString?

Think responses (“OK”) are noise — excluded from the brain’s transcript. Other tool responses are compressed to success/failure indicators only.

Returns:

  • (String, nil)

    ✅ or ❌ indicator, nil for think responses



52
53
54
55
56
# File 'app/decorators/tool_response_decorator.rb', line 52

def render_brain
  return if think?

  (payload["success"] != false) ? "\u2705" : "\u274C"
end

#render_debugHash

Returns full tool response data with untruncated content, tool_use_id, and token estimate ‘:tool_response, tool: String, content: String, success: Boolean, tool_use_id: String|nil,

timestamp: Integer|nil, tokens: Integer, estimated: Boolean`.

Returns:

  • (Hash)

    full tool response data with untruncated content, tool_use_id, and token estimate ‘:tool_response, tool: String, content: String, success: Boolean, tool_use_id: String|nil,

    timestamp: Integer|nil, tokens: Integer, estimated: Boolean`
    


38
39
40
41
42
43
44
45
46
47
# File 'app/decorators/tool_response_decorator.rb', line 38

def render_debug
  {
    role: :tool_response,
    tool: tool_name,
    content: content,
    success: payload["success"] != false,
    tool_use_id: payload["tool_use_id"],
    timestamp: timestamp
  }.merge(token_info)
end

#render_verboseHash?

Think responses are hidden in verbose mode — the “OK” adds no information.

Returns:

  • (Hash, nil)

    structured tool response data, nil for think responses ‘:tool_response, tool: String, content: String, success: Boolean, timestamp: Integer|nil`



23
24
25
26
27
28
29
30
31
32
33
# File 'app/decorators/tool_response_decorator.rb', line 23

def render_verbose
  return if think?

  {
    role: :tool_response,
    tool: tool_name,
    content: truncate_lines(content, max_lines: 3),
    success: payload["success"] != false,
    timestamp: timestamp
  }
end