Module: Protege::ToolMixin::ClassMethods

Defined in:
lib/protege/extensions/tool_mixin.rb

Overview

Class-level DSL mixed into every tool class via Tool.included.

Instance Method Summary collapse

Instance Method Details

#description(text = nil) ⇒ String?

Declare or read the natural-language description shown to the LLM in the tool catalog.

With an argument, sets the description; with no argument, returns the previously declared value.

Parameters:

  • text (String, nil) (defaults to: nil)

    the description to set, or nil to read

Returns:

  • (String, nil)

    the current description



182
183
184
185
186
# File 'lib/protege/extensions/tool_mixin.rb', line 182

def description(text = nil)
  return @description if text.nil?

  @description = text
end

#idSymbol

Return the tool's symbolic identifier, derived from the class basename with the Tool suffix stripped and the rest snake_cased. Every concrete tool is named <Purpose>Tool by convention (so tool classes never collide with same-named models), yet the id the agent sees stays clean. Memoized per class.

Examples:

SendEmailTool   # => :send_email
HTTPFetchTool   # => :http_fetch
EchoTool        # => :echo
Read2Tool       # => :read2

Returns:

  • (Symbol)

    the tool id



212
213
214
# File 'lib/protege/extensions/tool_mixin.rb', line 212

def id
  @id ||= name.demodulize.delete_suffix('Tool').underscore.to_sym
end

#input_schema(schema = nil) ⇒ Hash?

Declare or read the JSON Schema describing this tool's input parameters.

With an argument, sets the schema; with no argument, returns the previously declared value.

Parameters:

  • schema (Hash, nil) (defaults to: nil)

    the JSON Schema to set, or nil to read

Returns:

  • (Hash, nil)

    the current input schema



194
195
196
197
198
# File 'lib/protege/extensions/tool_mixin.rb', line 194

def input_schema(schema = nil)
  return @input_schema if schema.nil?

  @input_schema = schema
end