Class: Mistri::ToolResult
- Inherits:
-
Data
- Object
- Data
- Mistri::ToolResult
- Defined in:
- lib/mistri/tool_result.rb
Overview
A tool result with model content, host-only UI, and an explicit failure fact. Both channels and the error bit persist with the tool message; only content and provider-supported error signaling reach the model.
Tool.define("edit_page", "Edits the page.", schema: -> {
object :changes, "Page changes", required: true
}) do |args|
page = apply(args.fetch("changes"))
Mistri::ToolResult.new(content: "Updated.", ui: { "html" => page })
end
ui must be JSON-serializable; it is stored and delivered in canonical JSON form (string keys), the same shape a reloaded session reads.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#ui ⇒ Object
readonly
Returns the value of attribute ui.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(content:, ui: nil, error: false) ⇒ ToolResult
constructor
A new instance of ToolResult.
Constructor Details
#initialize(content:, ui: nil, error: false) ⇒ ToolResult
Returns a new instance of ToolResult.
18 19 20 21 22 23 24 |
# File 'lib/mistri/tool_result.rb', line 18 def initialize(content:, ui: nil, error: false) unless [true, false].include?(error) raise ArgumentError, "tool result error must be true or false" end super end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content
17 18 19 |
# File 'lib/mistri/tool_result.rb', line 17 def content @content end |
#error ⇒ Object (readonly)
Returns the value of attribute error
17 18 19 |
# File 'lib/mistri/tool_result.rb', line 17 def error @error end |
#ui ⇒ Object (readonly)
Returns the value of attribute ui
17 18 19 |
# File 'lib/mistri/tool_result.rb', line 17 def ui @ui end |
Instance Method Details
#error? ⇒ Boolean
26 |
# File 'lib/mistri/tool_result.rb', line 26 def error? = error |