Class: Boxcars::StationAgent::HandoffBoxcar
- Defined in:
- lib/boxcars/train/station_agent.rb
Overview
Boxcar that wraps a target agent for handoff semantics. When the LLM calls this tool, ToolTrain exits its loop (return_direct: true) and the caller can inspect @pending_handoff for the target agent.
Constant Summary
Constants inherited from Boxcar
Boxcar::SCHEMA_KEY_ALIASES, Boxcar::TYPE_ALIASES
Instance Attribute Summary collapse
-
#target_agent ⇒ Object
readonly
Returns the value of attribute target_agent.
Attributes inherited from Boxcar
#description, #name, #parameters, #return_direct
Instance Method Summary collapse
- #call(inputs:) ⇒ Object
-
#initialize(target_agent) ⇒ HandoffBoxcar
constructor
A new instance of HandoffBoxcar.
- #input_keys ⇒ Object
Methods inherited from Boxcar
#apply, assi, #conduct, #conduct_result, hist, #output_keys, #parameters_json_schema, #run, #run_result, #schema, syst, #tool_call_name, #tool_definition, #tool_spec, user, #validate_inputs, #validate_outputs
Constructor Details
#initialize(target_agent) ⇒ HandoffBoxcar
Returns a new instance of HandoffBoxcar.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/boxcars/train/station_agent.rb', line 22 def initialize(target_agent) @target_agent = target_agent sanitized = target_agent.name.to_s.gsub(/[^\w-]+/, "_").gsub(/\A_+|_+\z/, "").downcase super( name: "handoff_to_#{sanitized}", description: "Hand off the conversation to #{target_agent.name}: #{target_agent.description}", return_direct: true, parameters: { reason: { type: :string, required: true, description: "Why this handoff is needed" } } ) end |
Instance Attribute Details
#target_agent ⇒ Object (readonly)
Returns the value of attribute target_agent.
20 21 22 |
# File 'lib/boxcars/train/station_agent.rb', line 20 def target_agent @target_agent end |
Instance Method Details
#call(inputs:) ⇒ Object
39 40 41 42 |
# File 'lib/boxcars/train/station_agent.rb', line 39 def call(inputs:) reason = inputs[:reason] || inputs["reason"] || "No reason given" { answer: Result.from_text("Handing off to #{target_agent.name}: #{reason}") } end |
#input_keys ⇒ Object
35 36 37 |
# File 'lib/boxcars/train/station_agent.rb', line 35 def input_keys [:reason] end |