class LittleGhost::Tool::Binding
Supply run-scoped collaborators when tools are instantiated outside an agent. A binding can be copied with selected collaborators replaced.
Tool instances expose the bound agent, run, runtime, model, workspace, and sandbox through matching accessors. ToolRegistry and Agent normally create bindings on behalf of application code.
Attributes
Agent, run, runtime, model, workspace, and sandbox available to a tool.
Agent, run, runtime, model, workspace, and sandbox available to a tool.
Agent, run, runtime, model, workspace, and sandbox available to a tool.
Public Class Methods
# File lib/little_ghost/tool.rb, line 55 def initialize(agent: nil, run: nil, runtime: nil, model: nil, workspace: nil, sandbox: nil) @agent = agent @run = run @runtime = runtime @model = model @workspace = workspace @sandbox = sandbox end
Creates a binding from any available run-scoped collaborators.
Public Instance Methods
Source
# File lib/little_ghost/tool.rb, line 71 def build(*tool_classes) tool_classes.flatten.map { |tool_class| tool_class.new(binding: self) } end
Instantiates each supplied tool class against this binding.
# File lib/little_ghost/tool.rb, line 65 def with(agent: self.agent, run: self.run, runtime: self.runtime, model: self.model, workspace: self.workspace, sandbox: self.sandbox) self.class.new(agent:, run:, runtime:, model:, workspace:, sandbox:) end
Copies the binding, replacing only the supplied collaborators.