Class: LittleGhost::Tool::ExecutionResult

Inherits:
Data
  • Object
show all
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

Instance Method Summary collapse

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_contentObject (readonly)

Returns the value of attribute companion_content

Returns:

  • (Object)

    the current value of companion_content



79
80
81
# File 'lib/little_ghost/tool.rb', line 79

def companion_content
  @companion_content
end

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



79
80
81
# File 'lib/little_ghost/tool.rb', line 79

def content
  @content
end

#errorObject (readonly)

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



79
80
81
# File 'lib/little_ghost/tool.rb', line 79

def error
  @error
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



79
80
81
# File 'lib/little_ghost/tool.rb', line 79

def status
  @status
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/little_ghost/tool.rb', line 95

def error?
  status == :error
end

#success?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/little_ghost/tool.rb', line 91

def success?
  status == :success
end