class Riffer::Agent::Config
Typed configuration object holding every class-level DSL setting on a Riffer::Agent subclass. Procs are stored unresolved and resolved per-instance later.
Constants
- DEFAULT_MAX_STEPS
Attributes
Registered guardrail entries keyed by phase.
The configured agent identifier.
The configured instructions.
The maximum number of LLM call steps in the tool-use loop.
The accumulated use_mcp tag configurations.
The configured model.
Options passed to generate_text/stream_text.
Options passed to the provider client.
The configured skills.
The configured structured-output schema.
The configured tool runtime.
The configured tools.
Public Class Methods
Source
# File lib/riffer/agent/config.rb, line 50 def initialize( identifier: nil, model: nil, instructions: nil, provider_options: {}, model_options: {}, structured_output: nil, max_steps: DEFAULT_MAX_STEPS, tools_config: nil, mcp_configs: [], tool_runtime: Riffer.config.tool_runtime, skills_config: nil, guardrails: {before: [], after: []} ) @provider_options = provider_options @model_options = model_options @max_steps = max_steps @tools_config = tools_config @mcp_configs = mcp_configs @skills_config = skills_config @guardrails = guardrails self.identifier = identifier self.model = model self.instructions = instructions self.structured_output = structured_output self.tool_runtime = tool_runtime end
Builds a new Config. Raises Riffer::ArgumentError if model or instructions is invalid (e.g. an empty string).
Public Instance Methods
Source
# File lib/riffer/agent/config.rb, line 134 def add_guardrail(phase, klass:, options: {}) valid_phases = [*Riffer::Guardrails::PHASES, :around] raise Riffer::ArgumentError, "Invalid guardrail phase: #{phase}" unless valid_phases.include?(phase) raise Riffer::ArgumentError, "Guardrail must be a Riffer::Guardrail subclass" unless klass.is_a?(Class) && klass <= Riffer::Guardrail cfg = {class: klass, options: options} case phase when :before @guardrails[:before] << cfg when :after @guardrails[:after] << cfg when :around @guardrails[:before] << cfg @guardrails[:after] << cfg end end
Appends a guardrail entry to guardrails for the given phase; :around appends to both :before and :after. Raises Riffer::ArgumentError unless phase is :before, :after, or :around.
Source
# File lib/riffer/agent/config.rb, line 124 def add_mcp(tag, progressive: true) raise Riffer::ArgumentError, "progressive must be a boolean" unless progressive == true || progressive == false @mcp_configs << {tags: [tag.to_sym], progressive: progressive} end
Appends an MCP tag entry to mcp_configs.
Source
# File lib/riffer/agent/config.rb, line 155 def guardrails_for(phase) @guardrails[phase] || [] end
Returns the guardrail entries for the given phase, or [] if none.
Source
# File lib/riffer/agent/config.rb, line 81 def identifier=(value) @identifier = value&.to_s end
Sets identifier, coercing the value to String.
Source
# File lib/riffer/agent/config.rb, line 115 def instructions=(value) validate_string_or_proc!(value, "instructions") @instructions = value end
Sets instructions. Raises Riffer::ArgumentError on an invalid value (e.g. an empty string).
Source
# File lib/riffer/agent/config.rb, line 106 def model=(value) validate_string_or_proc!(value, "model") @model = value end
Sets model. Raises Riffer::ArgumentError on an invalid value (e.g. an empty string).
Source
# File lib/riffer/agent/config.rb, line 88 def structured_output=(value) raise Riffer::ArgumentError, "structured_output must be a Riffer::Params" unless value.nil? || value.is_a?(Riffer::Params) @structured_output = value end
Sets structured_output. Raises Riffer::ArgumentError on an invalid value.
Source
# File lib/riffer/agent/config.rb, line 96 def tool_runtime=(value) valid = (value.is_a?(Class) && value < Riffer::Tools::Runtime) || value.is_a?(Riffer::Tools::Runtime) || value.is_a?(Proc) raise Riffer::ArgumentError, "tool_runtime must be a Riffer::Tools::Runtime subclass, instance, or a Proc" unless valid @tool_runtime = value end
Sets tool_runtime. Raises Riffer::ArgumentError on an invalid value.