Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/lib/tool_meta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def self.extended(base)
base.instance_variable_set(:@tool_params, T.let([], T::Array[ParamMetadata]))
base.instance_variable_set(:@tool_name, nil)
base.instance_variable_set(:@tool_description, nil)
base.instance_variable_set(:@tool_type, nil)
end

sig { returns(T::Array[T.class_of(Object)]) }
Expand All @@ -43,6 +44,11 @@ def tool_description(description)
@tool_description = description
end

sig { params(type: Symbol).void }
def tool_type(type)
@tool_type = type
end

sig do
params(
name: T.any(String, Symbol),
Expand Down Expand Up @@ -72,6 +78,7 @@ def tool_metadata
{
name: @tool_name || default_tool_name,
description: @tool_description || '',
type: @tool_type || :write,
params: @tool_params,
entrypoint: tool_entrypoint
}
Expand Down
1 change: 1 addition & 0 deletions app/lib/tool_schema/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def self.build(service_class)
{
name: metadata[:name],
description: metadata[:description],
type: metadata[:type],
params: params_ast,
return_type: type_info[:return_type],
entrypoint: entrypoint,
Expand Down
1 change: 1 addition & 0 deletions app/services/tools/meta_tool_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def summary_payload(schema)
{
name: schema[:name],
description: schema[:description],
type: schema[:type],
usage: usage_string(schema)
}
end
Expand Down
19 changes: 19 additions & 0 deletions test/meta_tool_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ def test_ruby_llm_tools_preserves_hooks
assert before_called, 'Before hook should be preserved when fetching via ruby_llm_tools'
end

def test_tool_type_metadata
Tools.const_set(:ReadService, Class.new do
extend T::Sig
extend ToolMeta

tool_name 'read_stuff'
tool_description 'Read some stuff'
tool_type :read

sig { void }
def call; end
end)

schema = ToolSchema::Builder.build(Tools::ReadService)
assert_equal :read, schema[:type]

Tools.send(:remove_const, :ReadService)
end

private

def meta_service
Expand Down