Class: Riffer::Skills::ActivateTool

Inherits:
Tool
  • Object
show all
Defined in:
lib/riffer/skills/activate_tool.rb

Overview

Tool the LLM calls to activate a skill and receive its instructions; registered automatically when an agent has skills configured.

Constant Summary

Constants included from Tools::Toolable

Tools::Toolable::DEFAULT_TIMEOUT

Instance Method Summary collapse

Methods inherited from Tool

#call_with_validation, #error, #json, #text

Methods included from Tools::Toolable

all, #description, extended, #identifier, #kind, #name, #parameters_schema, #params, #timeout, #to_tool_schema, #validate_as_tool!

Instance Method Details

#call(context:, name:) ⇒ Object

Activates a skill by name and returns its wrapped body, or a short pointer when the skill is already active. – : (context: Riffer::Agent::Context?, name: String) -> Riffer::Tools::Response



19
20
21
22
23
24
25
26
27
28
# File 'lib/riffer/skills/activate_tool.rb', line 19

def call(context:, name:)
  skills_context = context&.skills
  return error("Skills not configured") unless skills_context
  return error("Unknown skill: '#{name}'") unless skills_context.model_invocable?(name)
  return text(already_active_message(name)) if skills_context.activated?(name)

  text(skills_context.activation_prompt(name))
rescue Riffer::ArgumentError => e
  error(e.message)
end