Class: OpenRouter::SubagentTool
- Defined in:
- lib/open_router/subagent_tool.rb
Overview
Represents the openrouter:subagent server tool, which lets an orchestrator
model delegate self-contained subtasks to a cheaper worker model mid-generation.
Unlike a function Tool, it serializes to the server-tool shape:
{ type: "openrouter:subagent", parameters: { model:, instructions:, ... } }
Constant Summary collapse
- SERVER_TOOL_TYPE =
"openrouter:subagent"
Instance Attribute Summary
Attributes inherited from Tool
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(model:, instructions: nil, max_completion_tokens: nil, temperature: nil, reasoning: nil) ⇒ SubagentTool
constructor
We deliberately do not call super: Tool#initialize expects a function definition with a name/description and validates it, neither of which a server tool has.
- #name ⇒ Object
- #parameters ⇒ Object
- #to_h ⇒ Object
Methods inherited from Tool
Constructor Details
#initialize(model:, instructions: nil, max_completion_tokens: nil, temperature: nil, reasoning: nil) ⇒ SubagentTool
We deliberately do not call super: Tool#initialize expects a function definition with a name/description and validates it, neither of which a server tool has. The server-tool shape is built directly here instead.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/open_router/subagent_tool.rb', line 21 def initialize(model:, instructions: nil, max_completion_tokens: nil, # rubocop:disable Lint/MissingSuper temperature: nil, reasoning: nil) raise ArgumentError, "model is required for SubagentTool" if model.nil? || model.to_s.strip.empty? @type = SERVER_TOOL_TYPE @parameters_config = { model: model, instructions: instructions, max_completion_tokens: max_completion_tokens, temperature: temperature, reasoning: reasoning }.compact end |
Instance Method Details
#description ⇒ Object
43 44 45 |
# File 'lib/open_router/subagent_tool.rb', line 43 def description "OpenRouter subagent server tool (worker: #{@parameters_config[:model]})" end |
#name ⇒ Object
39 40 41 |
# File 'lib/open_router/subagent_tool.rb', line 39 def name @type end |
#parameters ⇒ Object
47 48 49 |
# File 'lib/open_router/subagent_tool.rb', line 47 def parameters nil end |
#to_h ⇒ Object
35 36 37 |
# File 'lib/open_router/subagent_tool.rb', line 35 def to_h { type: @type, parameters: @parameters_config } end |