Module: RubyLLM::Skills::AgentExtensions

Defined in:
lib/ruby_llm/skills/agent_extensions.rb

Overview

Extensions for RubyLLM::Agent to enable declarative skill configuration.

Examples:

Static skills

class SupportAgent < RubyLLM::Agent
  skills "app/skills", only: [:faq]
end

Dynamic skills

class WorkspaceAgent < RubyLLM::Agent
  inputs :workspace
  skills { [workspace.skill_collection] }
end

Defined Under Namespace

Modules: ClassMethods, ConfigurationPatch, InstanceMethods

Constant Summary collapse

REQUIRED_AGENT_SINGLETON_METHODS =
%i[apply_configuration runtime_context llm_chat_for].freeze

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/ruby_llm/skills/agent_extensions.rb', line 132

def self.included(base)
  missing_methods = REQUIRED_AGENT_SINGLETON_METHODS.reject do |method_name|
    base.singleton_class.private_method_defined?(method_name) || base.singleton_class.method_defined?(method_name)
  end

  if missing_methods.any?
    raise LoadError,
      "RubyLLM::Agent is missing required methods for ruby_llm-skills integration: #{missing_methods.join(", ")}"
  end

  base.extend(ClassMethods)
  base.include(InstanceMethods)
  base.singleton_class.prepend(ConfigurationPatch)
end