Class: Mistri::ToolResult
- Inherits:
-
Data
- Object
- Data
- Mistri::ToolResult
- 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
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#ui ⇒ Object
readonly
Returns the value of attribute ui.
Instance Method Summary collapse
-
#initialize(content:, ui: nil) ⇒ ToolResult
constructor
A new instance of ToolResult.
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
#content ⇒ Object (readonly)
Returns the value of attribute content
18 19 20 |
# File 'lib/mistri/tool_result.rb', line 18 def content @content end |
#ui ⇒ Object (readonly)
Returns the value of attribute ui
18 19 20 |
# File 'lib/mistri/tool_result.rb', line 18 def ui @ui end |