Class: Phronomy::Agent::Handoff
- Inherits:
-
Object
- Object
- Phronomy::Agent::Handoff
- Defined in:
- lib/phronomy/agent/handoff.rb
Overview
Represents a transfer edge from one agent to another.
Creates an anonymous Phronomy::Tool::Base subclass that the source agent
exposes to the LLM as a +transfer_to_
Constant Summary collapse
- SENTINEL_PREFIX =
Prefix embedded in tool results so Runner can detect handoffs.
"__PHRONOMY_HANDOFF__"
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#target_agent ⇒ Object
readonly
Returns the value of attribute target_agent.
-
#tool_name ⇒ Object
readonly
Returns the value of attribute tool_name.
Instance Method Summary collapse
-
#initialize(target_agent:, description: nil) ⇒ Handoff
constructor
A new instance of Handoff.
-
#sentinel ⇒ String
The sentinel string embedded in the tool result.
-
#to_tool_class ⇒ Class<Phronomy::Tool::Base>
Builds an anonymous Phronomy::Tool::Base subclass for this handoff.
Constructor Details
#initialize(target_agent:, description: nil) ⇒ Handoff
Returns a new instance of Handoff.
23 24 25 26 27 28 |
# File 'lib/phronomy/agent/handoff.rb', line 23 def initialize(target_agent:, description: nil) @target_agent = target_agent klass_name = target_agent.class.name&.split("::")&.last || "Agent" @tool_name = "transfer_to_#{snake_case(klass_name)}" @description = description || "Transfer the conversation to #{klass_name}." end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
19 20 21 |
# File 'lib/phronomy/agent/handoff.rb', line 19 def description @description end |
#target_agent ⇒ Object (readonly)
Returns the value of attribute target_agent.
19 20 21 |
# File 'lib/phronomy/agent/handoff.rb', line 19 def target_agent @target_agent end |
#tool_name ⇒ Object (readonly)
Returns the value of attribute tool_name.
19 20 21 |
# File 'lib/phronomy/agent/handoff.rb', line 19 def tool_name @tool_name end |
Instance Method Details
#sentinel ⇒ String
The sentinel string embedded in the tool result.
45 46 47 |
# File 'lib/phronomy/agent/handoff.rb', line 45 def sentinel "#{SENTINEL_PREFIX}:#{target_agent.class.name}" end |
#to_tool_class ⇒ Class<Phronomy::Tool::Base>
Builds an anonymous Phronomy::Tool::Base subclass for this handoff.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/phronomy/agent/handoff.rb', line 32 def to_tool_class sentinel_value = sentinel tn = tool_name desc = description Class.new(Phronomy::Tool::Base) do tool_name tn description desc define_method(:execute) { sentinel_value } end end |