Files
google--adk-python/contributing/samples/workflows/node_as_tool
wehub-resource-sync ec2b666284
Continuous Integration / Pre-commit Linter (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.10) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.11) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.12) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.10) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.11) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.12) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.14) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.10) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.11) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.12) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.13) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.14) (push) Waiting to run
Copybara PR Handler / close-imported-pr (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:25:13 +08:00
..

Node as Tool

Overview

Demonstrates wrapping both a regular ADK Node (using the @node decorator) and a Workflow as tools that can be automatically called by a parent Agent.

In this sample:

  1. The parent agent receives an inquiry about a customer's discount.
  2. It invokes customer_lookup_workflow (a Workflow wrapped as a tool) to retrieve customer status.
  3. It then invokes calculate_discount (a regular Node wrapped as a tool) using the retrieved status.

Sample Inputs

  • What discount does customer c123 get?

    The parent agent first invokes customer_lookup_workflow to verify status, then invokes calculate_discount to determine the discount percentage, and summarizes the results.

Agent Topology Graph

graph TD
    customer_service_agent[customer_service_agent] -->|calls| customer_lookup_workflow(customer_lookup_workflow)
    customer_service_agent -->|calls| calculate_discount(calculate_discount)

How To

To expose an existing Node or Workflow as a tool callable by an Agent:

  1. Define your Node (or @node) or Workflow and assign both an input_schema and a description.
  2. Pass the node/workflow directly into your parent agent's tools list: Agent(..., tools=[my_node, my_workflow]).
  • Workflows - Explains building complex multi-step graphs.