Class: Xeno::AgentConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/xeno/agent_config.rb

Overview

The config DSL evaluated from agent/agent.rb. Optional — defaults apply when the file is absent.

Xeno.agent do
model "anthropic/claude-sonnet-5"
end

Any RubyLLM chat options ride along:

Xeno.agent do
model "my-model", provider: :ollama, assume_model_exists: true
end

Instance Method Summary collapse

Constructor Details

#initializeAgentConfig

Returns a new instance of AgentConfig.



16
17
18
19
20
# File 'lib/xeno/agent_config.rb', line 16

def initialize
  @model_id = nil
  @model_options = {}
  @limits = {}
end

Instance Method Details

#limits(**caps) ⇒ Object

Per-agent token budgets, overriding the global config:

Xeno.agent do
limits input_tokens: 2_000_000, output_tokens: 200_000
end

false disables an axis even when a global cap is set; an axis left out inherits the global Xeno.config.max_*_tokens_per_session.



30
31
32
33
34
35
36
37
38
# File 'lib/xeno/agent_config.rb', line 30

def limits(**caps)
  unless caps.empty?
    unknown = caps.keys - %i[input_tokens output_tokens]
    raise ArgumentError, "unknown limit axes: #{unknown.join(', ')}" if unknown.any?

    @limits = @limits.merge(caps)
  end
  @limits
end

#model(id = nil, **options) ⇒ Object

DSL setter and reader in one: model "id", **options inside the block, config.model afterwards.



50
51
52
53
54
55
56
# File 'lib/xeno/agent_config.rb', line 50

def model(id = nil, **options)
  if id
    @model_id = id
    @model_options = options
  end
  @model_id
end

#model_optionsObject



58
59
60
# File 'lib/xeno/agent_config.rb', line 58

def model_options
  @model_options
end

#resolved_modelObject



62
63
64
# File 'lib/xeno/agent_config.rb', line 62

def resolved_model
  @model_id || RubyLLM.config.default_model
end

#token_limit(axis, global) ⇒ Object

The effective cap for one axis: agent override first (false = off), then the global config. nil = unlimited.



42
43
44
45
46
# File 'lib/xeno/agent_config.rb', line 42

def token_limit(axis, global)
  return nil if @limits[axis] == false

  @limits.fetch(axis, nil) || global
end