class Riffer::Agent::Config
rbs_inline: enabled
Constants
- DEFAULT_MAX_STEPS
- DEFERRED_TOOLS_STRATEGIES
- REASONING_LEVELS
- STRUCTURED_OUTPUT_STRATEGIES
Attributes
@rbs @tool_runtime: (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)?
Public Class Methods
Source
# File lib/riffer/agent/config.rb, line 46 def initialize( identifier: nil, model: nil, instructions: nil, model_options: {}, structured_output: nil, structured_output_strategy: :native, max_steps: DEFAULT_MAX_STEPS, reasoning: nil, tools_config: nil, deferred_tools_config: nil, deferred_tools_strategy: :native, mcp_configs: [], tool_runtime: nil, skills_config: nil, guardrails: { before: [], after: [] } ) @model_options = model_options @max_steps = max_steps @tools_config = tools_config @deferred_tools_config = deferred_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.structured_output_strategy = structured_output_strategy self.deferred_tools_strategy = deferred_tools_strategy self.reasoning = reasoning self.tool_runtime = tool_runtime if tool_runtime end
Public Instance Methods
Source
# File lib/riffer/agent/config.rb, line 174 def add_guardrail(phase, klass:, options: {}) valid_phases = [*Riffer::Guardrails::PHASES, :around] raise Riffer::ArgumentError, "Invalid guardrail phase: #{phase}" unless valid_phases.include?(phase) unless klass.is_a?(Class) && klass <= Riffer::Guardrail raise Riffer::ArgumentError, "Guardrail must be a Riffer::Guardrail subclass" end 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
Source
# File lib/riffer/agent/config.rb, line 166 def add_mcp(tag, progressive: true) raise Riffer::ArgumentError, "progressive must be a boolean" unless [true, false].include?(progressive) @mcp_configs << { tags: [tag.to_sym], progressive: progressive } end
Source
# File lib/riffer/agent/config.rb, line 109 def deferred_tools_strategy=(value) unless DEFERRED_TOOLS_STRATEGIES.include?(value) raise Riffer::ArgumentError, "deferred_tools_strategy must be one of #{DEFERRED_TOOLS_STRATEGIES.inspect}, got #{value.inspect}" end @deferred_tools_strategy = value end
Source
# File lib/riffer/agent/config.rb, line 196 def guardrails_for(phase) @guardrails[phase] || [] end
Source
# File lib/riffer/agent/config.rb, line 82 def identifier=(value) @identifier = value&.to_s end
Source
# File lib/riffer/agent/config.rb, line 159 def instructions=(value) validate_string_or_proc!(value, "instructions") @instructions = value end
Source
# File lib/riffer/agent/config.rb, line 152 def model=(value) validate_string_or_proc!(value, "model") @model = value end
Source
# File lib/riffer/agent/config.rb, line 120 def reasoning=(value) level = value&.to_s&.to_sym unless level.nil? || REASONING_LEVELS.include?(level) raise Riffer::ArgumentError, "reasoning must be one of #{REASONING_LEVELS.join(', ')}, got #{value.inspect}" end @reasoning = level end
Source
# File lib/riffer/agent/config.rb, line 88 def structured_output=(value) unless value.nil? || value.is_a?(Riffer::Params) raise Riffer::ArgumentError, "structured_output must be a Riffer::Params" end @structured_output = value end
Source
# File lib/riffer/agent/config.rb, line 98 def structured_output_strategy=(value) unless STRUCTURED_OUTPUT_STRATEGIES.include?(value) raise Riffer::ArgumentError, "structured_output_strategy must be one of #{STRUCTURED_OUTPUT_STRATEGIES.inspect}, got #{value.inspect}" end @structured_output_strategy = value end
Source
# File lib/riffer/agent/config.rb, line 131 def tool_runtime # Resolved here rather than at construction so a copy can tell an inherited # runtime from a defaulted one. @tool_runtime || Riffer.config.tool_runtime end
Source
# File lib/riffer/agent/config.rb, line 139 def tool_runtime=(value) valid = (value.is_a?(Class) && value < Riffer::Tools::Runtime) || value.is_a?(Riffer::Tools::Runtime) || value.is_a?(Proc) unless valid raise Riffer::ArgumentError, "tool_runtime must be a Riffer::Tools::Runtime subclass, instance, or a Proc" end @tool_runtime = value end