Class: LittleGhost::Tool::ExecutionResult
- Inherits:
-
Data
- Object
- Data
- LittleGhost::Tool::ExecutionResult
- Defined in:
- lib/little_ghost/tool.rb,
lib/little_ghost/tool.rb
Overview
Reports the caller-safe outcome of one tool execution. It keeps model-facing content and status beside the original exception retained for application-side inspection. Companion content lets a tool place trusted text, images, or documents in the next model request without putting those blocks inside a provider-specific tool-result shape.
Instance Attribute Summary collapse
-
#companion_content ⇒ Object
readonly
Returns the value of attribute companion_content.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(content:, status:, error: nil, companion_content: []) ⇒ ExecutionResult
constructor
A new instance of ExecutionResult.
- #success? ⇒ Boolean
Constructor Details
#initialize(content:, status:, error: nil, companion_content: []) ⇒ ExecutionResult
Returns a new instance of ExecutionResult.
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/little_ghost/tool.rb', line 80 def initialize(content:, status:, error: nil, companion_content: []) companions = Array(companion_content) unless companions.all? do |block| block.is_a?(Content::Text) || block.is_a?(Content::Image) || block.is_a?(Content::Document) end raise ArgumentError, "companion content must contain only text, images, or documents" end super(content:, status:, error:, companion_content: companions.dup.freeze) end |
Instance Attribute Details
#companion_content ⇒ Object (readonly)
Returns the value of attribute companion_content
79 80 81 |
# File 'lib/little_ghost/tool.rb', line 79 def companion_content @companion_content end |
#content ⇒ Object (readonly)
Returns the value of attribute content
79 80 81 |
# File 'lib/little_ghost/tool.rb', line 79 def content @content end |
#error ⇒ Object (readonly)
Returns the value of attribute error
79 80 81 |
# File 'lib/little_ghost/tool.rb', line 79 def error @error end |
#status ⇒ Object (readonly)
Returns the value of attribute status
79 80 81 |
# File 'lib/little_ghost/tool.rb', line 79 def status @status end |
Instance Method Details
#error? ⇒ Boolean
95 96 97 |
# File 'lib/little_ghost/tool.rb', line 95 def error? status == :error end |
#success? ⇒ Boolean
91 92 93 |
# File 'lib/little_ghost/tool.rb', line 91 def success? status == :success end |