Module: SolidAgent::HasTools

Extended by:
ActiveSupport::Concern
Defined in:
lib/solid_agent/has_tools.rb

Defined Under Namespace

Classes: ToolBuilder

Instance Method Summary collapse

Instance Method Details

#reload_tools!Array<Hash>

Reloads tools, clearing any cached schemas.

Useful when tool templates may have changed during development.

Returns:

  • (Array<Hash>)

    freshly loaded tool schemas



124
125
126
127
# File 'lib/solid_agent/has_tools.rb', line 124

def reload_tools!
  @_tools_cache = nil
  tools
end

#toolsArray<Hash>

Returns all tool schemas for this agent.

Combines tools from:

  1. Auto-discovered JSON templates (if has_tools called without args)
  2. Explicitly listed tools (if has_tools called with args)
  3. Inline tool definitions (from tool blocks)

Returns:

  • (Array<Hash>)

    array of tool schemas in OpenAI format



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/solid_agent/has_tools.rb', line 101

def tools
  @_tools_cache ||= begin
    schemas = []

    # Load from templates
    if _tools_auto_discover
      schemas.concat(discover_tool_templates)
    elsif _tool_names.any?
      schemas.concat(_tool_names.map { |name| load_tool_schema(name) })
    end

    # Add inline tools
    schemas.concat(_inline_tools.values)

    schemas
  end
end