Class: Kernai::Agent
- Inherits:
-
Object
- Object
- Kernai::Agent
- Defined in:
- lib/kernai/agent.rb
Instance Attribute Summary collapse
-
#generation ⇒ Object
readonly
Returns the value of attribute generation.
-
#instructions ⇒ Object
Returns the value of attribute instructions.
-
#max_steps ⇒ Object
readonly
Returns the value of attribute max_steps.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#protocols ⇒ Object
Returns the value of attribute protocols.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#skills ⇒ Object
Returns the value of attribute skills.
Instance Method Summary collapse
-
#initialize(instructions:, provider: nil, model: Models::TEXT_ONLY, max_steps: 10, skills: nil, protocols: nil, generation: nil) ⇒ Agent
constructor
‘protocols` is a whitelist of Protocol block types this agent may address: nil → all registered protocols are allowed (default) [] → no protocol is allowed (explicit opt-out) [:mcp, :a2a] → only the named protocols are allowed.
- #resolve_instructions(workflow_enabled: true) ⇒ Object
- #update_instructions(text) ⇒ Object
Constructor Details
#initialize(instructions:, provider: nil, model: Models::TEXT_ONLY, max_steps: 10, skills: nil, protocols: nil, generation: nil) ⇒ Agent
‘protocols` is a whitelist of Protocol block types this agent may address:
nil → all registered protocols are allowed (default)
[] → no protocol is allowed (explicit opt-out)
[:mcp, :a2a] → only the named protocols are allowed
‘generation` is a Kernai::GenerationOptions describing provider-agnostic generation knobs (temperature, max_tokens, top_p, thinking, and vendor-specific extras). Accepts `nil`, a Hash, or an existing GenerationOptions instance.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kernai/agent.rb', line 17 def initialize(instructions:, provider: nil, model: Models::TEXT_ONLY, max_steps: 10, skills: nil, protocols: nil, generation: nil) raise ArgumentError, 'model: must be a Kernai::Model' unless model.is_a?(Model) @instructions = instructions @provider = provider @model = model @max_steps = max_steps @skills = skills @protocols = protocols @generation = GenerationOptions.coerce(generation) end |
Instance Attribute Details
#generation ⇒ Object (readonly)
Returns the value of attribute generation.
5 6 7 |
# File 'lib/kernai/agent.rb', line 5 def generation @generation end |
#instructions ⇒ Object
Returns the value of attribute instructions.
6 7 8 |
# File 'lib/kernai/agent.rb', line 6 def instructions @instructions end |
#max_steps ⇒ Object (readonly)
Returns the value of attribute max_steps.
5 6 7 |
# File 'lib/kernai/agent.rb', line 5 def max_steps @max_steps end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/kernai/agent.rb', line 5 def model @model end |
#protocols ⇒ Object
Returns the value of attribute protocols.
6 7 8 |
# File 'lib/kernai/agent.rb', line 6 def protocols @protocols end |
#provider ⇒ Object
Returns the value of attribute provider.
6 7 8 |
# File 'lib/kernai/agent.rb', line 6 def provider @provider end |
#skills ⇒ Object
Returns the value of attribute skills.
6 7 8 |
# File 'lib/kernai/agent.rb', line 6 def skills @skills end |
Instance Method Details
#resolve_instructions(workflow_enabled: true) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/kernai/agent.rb', line 30 def resolve_instructions(workflow_enabled: true) InstructionBuilder.new( @instructions, model: @model, skills: @skills, protocols: @protocols, workflow_enabled: workflow_enabled ).build end |
#update_instructions(text) ⇒ Object
40 41 42 |
# File 'lib/kernai/agent.rb', line 40 def update_instructions(text) @instructions = text end |