Class: SwarmSDK::Hooks::ToolResult
- Inherits:
-
Object
- Object
- SwarmSDK::Hooks::ToolResult
- Defined in:
- lib/swarm_sdk/hooks/tool_result.rb
Overview
Represents the result of a tool execution
This is a simple value object that wraps tool execution results in a consistent format for post-tool-use hooks.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#tool_call_id ⇒ Object
readonly
Returns the value of attribute tool_call_id.
-
#tool_name ⇒ Object
readonly
Returns the value of attribute tool_name.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
Check if the tool execution failed.
-
#initialize(tool_call_id:, tool_name:, content: nil, success: true, error: nil) ⇒ ToolResult
constructor
A new instance of ToolResult.
-
#success? ⇒ Boolean
Check if the tool execution succeeded.
-
#to_h ⇒ Hash
Convert to hash representation.
Constructor Details
#initialize(tool_call_id:, tool_name:, content: nil, success: true, error: nil) ⇒ ToolResult
26 27 28 29 30 31 32 |
# File 'lib/swarm_sdk/hooks/tool_result.rb', line 26 def initialize(tool_call_id:, tool_name:, content: nil, success: true, error: nil) @tool_call_id = tool_call_id @tool_name = tool_name @content = content @success = success @error = error end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
19 20 21 |
# File 'lib/swarm_sdk/hooks/tool_result.rb', line 19 def content @content end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
19 20 21 |
# File 'lib/swarm_sdk/hooks/tool_result.rb', line 19 def error @error end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
19 20 21 |
# File 'lib/swarm_sdk/hooks/tool_result.rb', line 19 def success @success end |
#tool_call_id ⇒ Object (readonly)
Returns the value of attribute tool_call_id.
19 20 21 |
# File 'lib/swarm_sdk/hooks/tool_result.rb', line 19 def tool_call_id @tool_call_id end |
#tool_name ⇒ Object (readonly)
Returns the value of attribute tool_name.
19 20 21 |
# File 'lib/swarm_sdk/hooks/tool_result.rb', line 19 def tool_name @tool_name end |
Instance Method Details
#failure? ⇒ Boolean
Check if the tool execution failed
44 45 46 |
# File 'lib/swarm_sdk/hooks/tool_result.rb', line 44 def failure? !@success end |
#success? ⇒ Boolean
Check if the tool execution succeeded
37 38 39 |
# File 'lib/swarm_sdk/hooks/tool_result.rb', line 37 def success? @success end |
#to_h ⇒ Hash
Convert to hash representation
51 52 53 54 55 56 57 58 59 |
# File 'lib/swarm_sdk/hooks/tool_result.rb', line 51 def to_h { tool_call_id: @tool_call_id, tool_name: @tool_name, content: @content, success: @success, error: @error, } end |