class Riffer::Skills::Context
Skills context for an agent generation cycle.
Coordinates skill discovery, activation, and prompt rendering. Tracks activations with caching to avoid redundant backend reads.
Built by the agent during Agent.new and exposed to tools via context.skills on the agentβs Riffer::Agent::Context.
Attributes
The skill adapter used for this context.
Optional callback invoked when a skill is first activated.
Skill catalog indexed by name.
Public Class Methods
Source
# File lib/riffer/skills/context.rb, line 35 def initialize(backend:, skills:, adapter:) @backend = backend @skills = skills @adapter = adapter @activated = {} #: Hash[String, String] end
Creates a new skills context for a generation cycle.
- backend
-
the skills backend for reading skill bodies.
- skills
-
skill catalog indexed by name.
- adapter
-
the adapter used to render skill content. The adapter carries the activation tool class via its initializer.
Public Instance Methods
Source
# File lib/riffer/skills/context.rb, line 48 def activate(name) raise Riffer::ArgumentError, "Unknown skill: '#{name}'" unless skills.key?(name) return @activated[name] if @activated.key?(name) @activated[name] = @backend.read_skill(name) @on_activate&.call(name) @activated[name] end
Activates a skill by name. Returns the cached body on re-activation.
Raises Riffer::ArgumentError if the skill is not in the catalog.
Source
# File lib/riffer/skills/context.rb, line 60 def activated?(name) @activated.key?(name) end
Returns whether a skill has been activated.
Source
# File lib/riffer/skills/context.rb, line 70 def system_prompt available = available_skills parts = [] #: Array[String] parts << @adapter.render_catalog(available) unless available.empty? @activated.each_value { |body| parts << body } parts.join("\n\n") end
Returns the complete skills section for the system prompt.
Includes the catalog and any pre-activated skill bodies.