Class: Mistri::ToolContext
- Inherits:
-
Data
- Object
- Data
- Mistri::ToolContext
- Defined in:
- lib/mistri/tool_context.rb
Overview
What a tool handler may know about the run it executes inside: the caller's session, the abort signal, the event stream, and the host's own context object. Handlers take it as an optional second argument — a proc ignores it invisibly, a lambda opts in by accepting two parameters. Sub-agents are built on it; any tool that spawns work, links records to the session, or streams progress can use it the same way.
app carries whatever the host passes as Agent.new(context:) — the acting user, a tenant, a request — untouched. The gem provides the slot, never the vocabulary:
agent = Mistri.agent("claude-opus-4-8", tools: tools,
context: { traveler: current_traveler })
Mistri::Tool.define("book_hotel", "Books the chosen hotel.") do |args, context|
Bookings.create(args, traveler: context.app[:traveler])
end
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#emit ⇒ Object
readonly
Returns the value of attribute emit.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#signal ⇒ Object
readonly
Returns the value of attribute signal.
Instance Method Summary collapse
-
#initialize(session: nil, signal: nil, emit: nil, app: nil) ⇒ ToolContext
constructor
A new instance of ToolContext.
Constructor Details
#initialize(session: nil, signal: nil, emit: nil, app: nil) ⇒ ToolContext
Returns a new instance of ToolContext.
22 23 24 |
# File 'lib/mistri/tool_context.rb', line 22 def initialize(session: nil, signal: nil, emit: nil, app: nil) super end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app
21 22 23 |
# File 'lib/mistri/tool_context.rb', line 21 def app @app end |
#emit ⇒ Object (readonly)
Returns the value of attribute emit
21 22 23 |
# File 'lib/mistri/tool_context.rb', line 21 def emit @emit end |
#session ⇒ Object (readonly)
Returns the value of attribute session
21 22 23 |
# File 'lib/mistri/tool_context.rb', line 21 def session @session end |
#signal ⇒ Object (readonly)
Returns the value of attribute signal
21 22 23 |
# File 'lib/mistri/tool_context.rb', line 21 def signal @signal end |