Class: Rubino::Agent::Definition
- Inherits:
-
Object
- Object
- Rubino::Agent::Definition
- Defined in:
- lib/rubino/agent/definition.rb
Overview
Defines an agent type with its own model, system prompt, permissions, and tools. Agents can be primary (user-facing) or subagents (invokable by other agents).
Constant Summary collapse
- SUBAGENT_ONLY_TOOLS =
Tools that ONLY make sense for a subagent and must be hidden from a primary/top-level agent. ask_parent escalates a question to the PARENT — a top-level agent has no parent, so exposing it there would be a dead tool. Subagents keep it; everyone else drops it. This is the single enforcement point and is UNCHANGED by S1 (re-enabling nesting does not expose ask_parent to top-level agents).
%w[ask_parent].freeze
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#system_prompt ⇒ Object
readonly
Returns the value of attribute system_prompt.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #hidden? ⇒ Boolean
-
#initialize(attrs = {}) ⇒ Definition
constructor
Types: :primary (user-switchable), :subagent (invokable), :utility (hidden).
-
#max_turns ⇒ Object
Returns the max turns for this agent (falls back to global config).
-
#mcp_servers ⇒ Object
Which MCP servers this agent may use: :all, or an array of server names.
- #primary? ⇒ Boolean
-
#resolved_model ⇒ Object
Returns the resolved model (falls back to global default).
- #resolved_tools ⇒ Object
- #subagent? ⇒ Boolean
Constructor Details
#initialize(attrs = {}) ⇒ Definition
Types: :primary (user-switchable), :subagent (invokable), :utility (hidden)
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rubino/agent/definition.rb', line 12 def initialize(attrs = {}) @name = attrs[:name] @type = attrs[:type] || :primary @model = attrs[:model] @system_prompt = attrs[:system_prompt] @description = attrs[:description] || "" @permissions = attrs[:permissions] || {} @mcp_servers = attrs[:mcp_servers] # :all or array of server names @tools = attrs[:tools] || :all # :all, :read_only, or array of tool names @hidden = attrs[:hidden] || false @max_turns = attrs[:max_turns] end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/rubino/agent/definition.rb', line 8 def description @description end |
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden.
8 9 10 |
# File 'lib/rubino/agent/definition.rb', line 8 def hidden @hidden end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
8 9 10 |
# File 'lib/rubino/agent/definition.rb', line 8 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/rubino/agent/definition.rb', line 8 def name @name end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
8 9 10 |
# File 'lib/rubino/agent/definition.rb', line 8 def @permissions end |
#system_prompt ⇒ Object (readonly)
Returns the value of attribute system_prompt.
8 9 10 |
# File 'lib/rubino/agent/definition.rb', line 8 def system_prompt @system_prompt end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
8 9 10 |
# File 'lib/rubino/agent/definition.rb', line 8 def tools @tools end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/rubino/agent/definition.rb', line 8 def type @type end |
Instance Method Details
#hidden? ⇒ Boolean
33 34 35 |
# File 'lib/rubino/agent/definition.rb', line 33 def hidden? @hidden end |
#max_turns ⇒ Object
Returns the max turns for this agent (falls back to global config)
54 55 56 |
# File 'lib/rubino/agent/definition.rb', line 54 def max_turns @max_turns || Rubino.configuration.agent_max_turns end |
#mcp_servers ⇒ Object
Which MCP servers this agent may use: :all, or an array of server names. An explicit value passed in code wins; otherwise the ‘agents.<name>.mcp_servers` block in config.yml applies (#92), and absent both the agent sees every server. YAML has no symbols, so the literal string “all” from config normalizes to :all — the value #resolved_tools compares against.
43 44 45 46 47 48 49 50 51 |
# File 'lib/rubino/agent/definition.rb', line 43 def mcp_servers return @mcp_servers if @mcp_servers configured = Rubino.configuration.dig("agents", name.to_s, "mcp_servers") case configured when Array then configured.map(&:to_s) else :all end end |
#primary? ⇒ Boolean
25 26 27 |
# File 'lib/rubino/agent/definition.rb', line 25 def primary? @type == :primary end |
#resolved_model ⇒ Object
Returns the resolved model (falls back to global default)
59 60 61 |
# File 'lib/rubino/agent/definition.rb', line 59 def resolved_model @model || Rubino.configuration.model_default end |
#resolved_tools ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rubino/agent/definition.rb', line 79 def resolved_tools tools = case @tools when :all Tools::Registry.enabled_tools when :read_only Tools::Registry.enabled_tools.select { |t| t.risk_level == :low } when Array @tools.filter_map { |name| Tools::Registry.find(name) } else Tools::Registry.enabled_tools end # Per-agent MCP scoping (#92/#173): every consumer of this agent's tool # set (Lifecycle#load_tools, prompt assembler) goes through here, so # filtering MCP wrappers HERE is what actually keeps an out-of-scope # server's tools away from the model. tools = reject_unscoped_mcp_tools(tools) # ask_parent is subagent-only; a primary/top-level agent has no parent. # Nesting is otherwise allowed for everyone — the delegation tools stay. if subagent? tools else tools.reject { |t| SUBAGENT_ONLY_TOOLS.include?(t.name) } end end |
#subagent? ⇒ Boolean
29 30 31 |
# File 'lib/rubino/agent/definition.rb', line 29 def subagent? @type == :subagent end |