Class: Phronomy::Tools::Agent
- Inherits:
-
Agent::Context::Capability::Base
- Object
- RubyLLM::Tool
- Agent::Context::Capability::Base
- Phronomy::Tools::Agent
- Defined in:
- lib/phronomy/tools/agent.rb
Overview
Wraps a Phronomy::Agent::Base subclass as a callable tool so that a parent agent can delegate a one-shot sub-task through the same stateful pipeline.
Class Method Summary collapse
Methods inherited from Agent::Context::Capability::Base
approval_facts, #approval_metadata, #call, #call_async, description, #execute, execution_mode, max_result_size, #name, on_error, on_schema_error, param, param_enums, param_schemas, parameters, #params_schema, params_schema_definition, provider_params, redact_params, requires_approval, #requires_approval, #requires_approval?, tool_name, #tool_origin
Class Method Details
.from_agent(agent_class, tool_name: nil, description: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/phronomy/tools/agent.rb', line 12 def from_agent(agent_class, tool_name: nil, description: nil) raise ArgumentError, "agent_class must be a Class" unless agent_class.is_a?(Class) unless agent_class <= Phronomy::Agent::Base raise ArgumentError, "agent_class must inherit from Phronomy::Agent::Base" end # Fail at Tool definition time rather than on the first Tool call. agent_class.agent_definition klass = Class.new(self) effective_name = tool_name || derive_name(agent_class) effective_desc = description || "Delegates to #{agent_class.name || "an agent"}" klass.tool_name(effective_name) klass.description(effective_desc) klass.define_method(:execute) do |input:| result = Phronomy::Agent.run_once( definition: agent_class, input: input ) result[:output].to_s end klass end |