Class: ActiveAgent::Providers::RubyLLM::ToolProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/active_agent/providers/ruby_llm/tool_proxy.rb

Overview

Bridges ActiveAgent tool definitions to RubyLLM’s expected tool interface. RubyLLM expects tools as { “name” => tool } where each tool responds to #name, #description, #parameters, #params_schema, and #provider_params.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, description:, parameters:) ⇒ ToolProxy

Returns a new instance of ToolProxy.



12
13
14
15
16
# File 'lib/active_agent/providers/ruby_llm/tool_proxy.rb', line 12

def initialize(name:, description:, parameters:)
  @name = name
  @description = description
  @parameters = parameters
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



10
11
12
# File 'lib/active_agent/providers/ruby_llm/tool_proxy.rb', line 10

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/active_agent/providers/ruby_llm/tool_proxy.rb', line 10

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



10
11
12
# File 'lib/active_agent/providers/ruby_llm/tool_proxy.rb', line 10

def parameters
  @parameters
end

Instance Method Details

#params_schemaObject

RubyLLM checks this first; returns the JSON Schema directly so RubyLLM doesn’t try to interpret our parameters as Parameter objects. Deep-stringifies keys to match RubyLLM’s internal schema format.



21
22
23
# File 'lib/active_agent/providers/ruby_llm/tool_proxy.rb', line 21

def params_schema
  deep_stringify(@parameters) if @parameters.is_a?(Hash) && @parameters.any?
end

#provider_paramsObject

RubyLLM merges this into the tool definition



26
27
28
# File 'lib/active_agent/providers/ruby_llm/tool_proxy.rb', line 26

def provider_params
  {}
end