Class: AgentHarness::SubAgentConfig
- Inherits:
-
Object
- Object
- AgentHarness::SubAgentConfig
- Defined in:
- lib/agent_harness/sub_agent_config.rb
Overview
Canonical provider-agnostic sub-agent definition.
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#handoff_conditions ⇒ Object
readonly
Returns the value of attribute handoff_conditions.
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
-
#mcp_servers ⇒ Object
readonly
Returns the value of attribute mcp_servers.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#routing ⇒ Object
readonly
Returns the value of attribute routing.
-
#sub_agents ⇒ Object
readonly
Returns the value of attribute sub_agents.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, description:, instructions:, model: "default", tools: [], mcp_servers: [], constraints: {}, handoff_conditions: [], type: nil, sub_agents: [], routing: nil) ⇒ SubAgentConfig
constructor
A new instance of SubAgentConfig.
- #to_h ⇒ Object
Constructor Details
#initialize(name:, description:, instructions:, model: "default", tools: [], mcp_servers: [], constraints: {}, handoff_conditions: [], type: nil, sub_agents: [], routing: nil) ⇒ SubAgentConfig
Returns a new instance of SubAgentConfig.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/agent_harness/sub_agent_config.rb', line 9 def initialize(name:, description:, instructions:, model: "default", tools: [], mcp_servers: [], constraints: {}, handoff_conditions: [], type: nil, sub_agents: [], routing: nil) @name = normalize_name(name) @description = validate_string!(:description, description) @instructions = validate_string!(:instructions, instructions) @model = normalize_model(model) @tools = normalize_array(:tools, tools) @mcp_servers = normalize_array(:mcp_servers, mcp_servers) @constraints = normalize_hash(:constraints, constraints) @handoff_conditions = normalize_array(:handoff_conditions, handoff_conditions) @type = type&.to_sym @sub_agents = normalize_array(:sub_agents, sub_agents) @routing = routing.nil? ? nil : normalize_hash(:routing, routing) end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
7 8 9 |
# File 'lib/agent_harness/sub_agent_config.rb', line 7 def constraints @constraints end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/agent_harness/sub_agent_config.rb', line 6 def description @description end |
#handoff_conditions ⇒ Object (readonly)
Returns the value of attribute handoff_conditions.
7 8 9 |
# File 'lib/agent_harness/sub_agent_config.rb', line 7 def handoff_conditions @handoff_conditions end |
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
6 7 8 |
# File 'lib/agent_harness/sub_agent_config.rb', line 6 def instructions @instructions end |
#mcp_servers ⇒ Object (readonly)
Returns the value of attribute mcp_servers.
6 7 8 |
# File 'lib/agent_harness/sub_agent_config.rb', line 6 def mcp_servers @mcp_servers end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
6 7 8 |
# File 'lib/agent_harness/sub_agent_config.rb', line 6 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/agent_harness/sub_agent_config.rb', line 6 def name @name end |
#routing ⇒ Object (readonly)
Returns the value of attribute routing.
7 8 9 |
# File 'lib/agent_harness/sub_agent_config.rb', line 7 def routing @routing end |
#sub_agents ⇒ Object (readonly)
Returns the value of attribute sub_agents.
7 8 9 |
# File 'lib/agent_harness/sub_agent_config.rb', line 7 def sub_agents @sub_agents end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
6 7 8 |
# File 'lib/agent_harness/sub_agent_config.rb', line 6 def tools @tools end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/agent_harness/sub_agent_config.rb', line 7 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/agent_harness/sub_agent_config.rb', line 25 def self.from_hash(hash) unless hash.is_a?(Hash) raise ConfigurationError, "Sub-agent definition must be a Hash, got #{hash.class}" end attrs = hash.each_with_object({}) do |(key, value), memo| memo[key.to_sym] = value end %i[name description instructions].each do |field| value = attrs[field] next if value.is_a?(String) && !value.strip.empty? next if value.is_a?(Symbol) raise ConfigurationError, "#{field} is required" end new(**attrs) end |
Instance Method Details
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/agent_harness/sub_agent_config.rb', line 45 def to_h { name: @name, description: @description, instructions: @instructions, model: @model, tools: deep_dup(@tools), mcp_servers: deep_dup(@mcp_servers), constraints: deep_dup(@constraints), handoff_conditions: deep_dup(@handoff_conditions), type: @type, sub_agents: deep_dup(@sub_agents), routing: deep_dup(@routing) }.compact end |