Class: Roast::Cogs::Agent::Providers::Pi::Messages::ToolResultMessage
- Inherits:
-
Object
- Object
- Roast::Cogs::Agent::Providers::Pi::Messages::ToolResultMessage
- Defined in:
- lib/roast/cogs/agent/providers/pi/messages/tool_result_message.rb
Overview
Represents a tool execution result from the Pi agent
In Pi’s JSON protocol, tool results appear as ‘tool_execution_end` events containing the result content and error status.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
: String?.
-
#is_error ⇒ Object
readonly
: bool.
-
#tool_call_id ⇒ Object
readonly
: String?.
-
#tool_name ⇒ Object
readonly
: String?.
Instance Method Summary collapse
-
#format(context) ⇒ Object
: (PiInvocation::Context) -> String?.
-
#initialize(tool_call_id:, tool_name:, content:, is_error:) ⇒ ToolResultMessage
constructor
: (tool_call_id: String?, tool_name: String?, content: String?, is_error: bool) -> void.
Constructor Details
#initialize(tool_call_id:, tool_name:, content:, is_error:) ⇒ ToolResultMessage
: (tool_call_id: String?, tool_name: String?, content: String?, is_error: bool) -> void
28 29 30 31 32 33 |
# File 'lib/roast/cogs/agent/providers/pi/messages/tool_result_message.rb', line 28 def initialize(tool_call_id:, tool_name:, content:, is_error:) @tool_call_id = tool_call_id @tool_name = tool_name @content = content @is_error = is_error end |
Instance Attribute Details
#content ⇒ Object (readonly)
: String?
22 23 24 |
# File 'lib/roast/cogs/agent/providers/pi/messages/tool_result_message.rb', line 22 def content @content end |
#is_error ⇒ Object (readonly)
: bool
25 26 27 |
# File 'lib/roast/cogs/agent/providers/pi/messages/tool_result_message.rb', line 25 def is_error @is_error end |
#tool_call_id ⇒ Object (readonly)
: String?
16 17 18 |
# File 'lib/roast/cogs/agent/providers/pi/messages/tool_result_message.rb', line 16 def tool_call_id @tool_call_id end |
#tool_name ⇒ Object (readonly)
: String?
19 20 21 |
# File 'lib/roast/cogs/agent/providers/pi/messages/tool_result_message.rb', line 19 def tool_name @tool_name end |
Instance Method Details
#format(context) ⇒ Object
: (PiInvocation::Context) -> String?
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/roast/cogs/agent/providers/pi/messages/tool_result_message.rb', line 36 def format(context) tool_call = context.tool_call(tool_call_id) name = tool_name || tool_call&.name || "unknown" status = is_error ? "ERROR" : "OK" # Truncate long tool results for progress display c = content display_content = if c && c.length > 200 "#{c[0..197]}..." else c end "#{name.upcase} #{status}#{display_content ? " #{display_content}" : ""}" end |