class Riffer::Config
Configuration for the Riffer framework.
Provides configuration options for AI providers and other settings.
Riffer.config.openai.api_key = "sk-..." Riffer.config.amazon_bedrock.region = "us-east-1" Riffer.config.amazon_bedrock.api_token = "..." Riffer.config.anthropic.api_key = "sk-ant-..." Riffer.config.openrouter.api_key = "sk-or-..." Riffer.config.evals.judge_model = "anthropic/claude-sonnet-4-20250514"
Constants
- AmazonBedrock
- Anthropic
- AzureOpenAI
- Evals
- Gemini
- Mcp
- OpenAI
- OpenRouter
- VALID_MESSAGE_ID_STRATEGIES
Attributes
Amazon Bedrock configuration (Struct with api_token and region).
Anthropic configuration (Struct with api_key).
Azure OpenAI configuration (Struct with api_key and endpoint).
Experimental: when true, riffer keeps the tool_use ↔ tool_result invariant intact on its own.
-
On +Riffer::Agent#generate(messages_array)+, orphaned
tool_useexchanges and parentlessRiffer::Messages::Toolmessages are silently stripped from the seed. Pending tool calls on the resume boundary (last assistant whose tail is purely Tool results) are preserved forexecute_pending_tool_calls. -
On any interrupt (caller-issued
interrupt!orINTERRUPT_MAX_STEPS), riffer fills any orphanedtool_usewith a placeholderRiffer::Messages::Toolcarrying +error_type: :interrupted+, leaving history valid for the next turn. Filled call_ids are exposed on +Riffer::Agent::Response#healed_tool_call_ids+ (and the streamingRiffer::StreamEvents::Interruptevent).
Defaults to false — the pre-healing behavior. Experimental: the surface and default may change without notice.
Google Gemini configuration (Struct with api_key, open_timeout, and read_timeout).
MCP configuration (Struct with credentials and discovery_runner).
credentials is an optional Proc for per-run MCP tools/call HTTP headers. Signature: +->(manifest:, matched_tags:, context:) { Hash or nil }+. nil from the proc at tool-resolution time omits that server’s tools; nil at tool-call time raises Riffer::Mcp::CredentialsDeniedError.
discovery_runner is the Riffer::Runner used to execute tool discovery (default Runner::Sequential).
Strategy for auto-generating message ids. One of :none (default, no id), :uuid (UUIDv4), or :uuidv7 (time-ordered UUIDv7).
When set to anything other than :none, each Riffer::Messages::Base instance gets an id populated at construction time, and seeded messages passed to +Riffer::Agent#generate+ must carry their own :id.
OpenAI configuration (Struct with api_key).
OpenRouter configuration (Struct with api_key).
Skills-related global configuration. Returns a Riffer::Config::Skills object — see Riffer.config.skills.default_activate_tool.
Global tool runtime configuration (experimental).
Accepts a Riffer::Tools::Runtime subclass, a Riffer::Tools::Runtime instance, or a Proc. Defaults to Riffer::Tools::Runtime::Inline.new.
Public Class Methods
Source
# File lib/riffer/config.rb, line 203 def initialize @amazon_bedrock = AmazonBedrock.new @anthropic = Anthropic.new @azure_openai = AzureOpenAI.new @gemini = Gemini.new @openai = OpenAI.new @openrouter = OpenRouter.new @evals = Evals.new @mcp = Mcp.new(credentials: nil, discovery_runner: Riffer::Runner::Sequential.new) @tool_runtime = Riffer::Tools::Runtime::Inline.new @skills = Skills.new @message_id_strategy = :none @experimental_history_healing = false end
Public Instance Methods
Source
# File lib/riffer/config.rb, line 191 def experimental_history_healing=(value) @experimental_history_healing = case value when true, "true", 1, "1" then true when false, "false", 0, "0", nil then false else raise Riffer::ArgumentError, "experimental_history_healing must be a boolean (or 'true'/'false'/'1'/'0'/1/0), got #{value.inspect}" end end
Sets the experimental_history_healing flag.
Coerces common boolean representations so values pulled from environment variables don’t silently enable healing — the string +“false”+ is truthy in Ruby and would otherwise flip the flag on. Accepts true/false, +“true”/“false”+, 1/0, +“1”/“0”+, and nil (treated as false, the default). Raises Riffer::ArgumentError for any other value.
Source
# File lib/riffer/config.rb, line 152 def message_id_strategy=(value) unless VALID_MESSAGE_ID_STRATEGIES.include?(value) raise Riffer::ArgumentError, "message_id_strategy must be one of #{VALID_MESSAGE_ID_STRATEGIES.inspect}, got #{value.inspect}" end @message_id_strategy = value end
Sets the message id strategy.
Raises Riffer::ArgumentError if the value is not one of :none, :uuid, or :uuidv7.
Source
# File lib/riffer/config.rb, line 127 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 the global tool runtime.
Raises Riffer::ArgumentError if the value is not a valid runtime (ToolRuntime subclass, ToolRuntime instance, or Proc).