Class: Google::ADK::AgentTool
- Defined in:
- lib/google/adk/tools/agent_tool.rb
Overview
Tool that wraps another agent
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
Attributes inherited from BaseTool
Instance Method Summary collapse
-
#call(params = {}) ⇒ Object
Execute the wrapped agent.
-
#initialize(agent:) ⇒ AgentTool
constructor
Initialize an agent tool.
-
#schema ⇒ Hash
Get parameter schema.
Constructor Details
#initialize(agent:) ⇒ AgentTool
Initialize an agent tool
14 15 16 17 |
# File 'lib/google/adk/tools/agent_tool.rb', line 14 def initialize(agent:) super(name: agent.name, description: agent.description) @agent = agent end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
9 10 11 |
# File 'lib/google/adk/tools/agent_tool.rb', line 9 def agent @agent end |
Instance Method Details
#call(params = {}) ⇒ Object
Execute the wrapped agent
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/google/adk/tools/agent_tool.rb', line 23 def call(params = {}) = params[:message] || params["message"] || "" context = params[:context] # In a real implementation, this would run the agent # and collect its response if @agent.respond_to?(:run_async) # Collect all events from the agent events = [] @agent.run_async(, context: context).each do |event| events << event end # Return the last event's content as the result events.last&.content || "No response" else "Agent #{@agent.name} cannot be executed" end end |
#schema ⇒ Hash
Get parameter schema
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/google/adk/tools/agent_tool.rb', line 46 def schema { "type" => "object", "properties" => { "message" => { "type" => "string", "description" => "Message to send to the agent" } }, "required" => ["message"] } end |