Class: Mistri::ToolResult

Inherits:
Data
  • Object
show all
Defined in:
lib/mistri/tool_result.rb

Overview

A two-channel tool result: content goes to the model, ui goes only to the host. The ui payload rides the tool message and its :tool_result event, persists with the session for transcript re-renders, and never reaches a provider. Return one from a handler when the UI needs more than the model should read or pay for: full query rows behind a compact answer, the updated document behind "saved".

Tool.define("edit_page", "Edits the page.") do |args|
page = apply(args)
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

Instance Method Summary collapse

Constructor Details

#initialize(content:, ui: nil) ⇒ ToolResult

Returns a new instance of ToolResult.



19
20
21
# File 'lib/mistri/tool_result.rb', line 19

def initialize(content:, ui: nil)
  super
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



18
19
20
# File 'lib/mistri/tool_result.rb', line 18

def content
  @content
end

#uiObject (readonly)

Returns the value of attribute ui

Returns:

  • (Object)

    the current value of ui



18
19
20
# File 'lib/mistri/tool_result.rb', line 18

def ui
  @ui
end