-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed as not planned
Closed as not planned
Copy link
Labels
core[Component] This issue is related to the core interface and implementation[Component] This issue is related to the core interface and implementationquestion[Component] This issue is asking a question or clarification[Component] This issue is asking a question or clarification
Milestone
Description
...but I found that agent.parent_agent returns None, agent.root_agent returns the name of the parent agent
https://google.github.io/adk-docs/agents/multi-agents/#21-agent-hierarchy-parent_agent-sub_agents
Importance: This hierarchy defines the scope for Workflow Agents and influences the potential targets for LLM-Driven Delegation. You can navigate the hierarchy using agent.parent_agent or find descendants using agent.find_agent(name).
I think documentation should change to parent_agent = coordinator.root_agent.parent_agent
The code that I used is as below
import asyncio
from dotenv import load_dotenv
from google.adk import Runner
from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
from google.adk.sessions import InMemorySessionService
from google.genai import types
load_dotenv()
MODEL_GPT_4O = "openai/gpt-4o"
MODEL_GPT_4O_LITE_LLM = LiteLlm(model=MODEL_GPT_4O)
# Define constants for identifying the interaction context
APP_NAME = "tutor_app"
USER_ID = "user_1"
SESSION_ID = "session_001" # Using a fixed ID for simplicity
session_service = InMemorySessionService()
# Create the specific session where the conversation will happen
session = session_service.create_session(
app_name=APP_NAME,
user_id=USER_ID,
session_id=SESSION_ID
)
math_agent = LlmAgent(name="Math",
description="Handles math question",
model=MODEL_GPT_4O_LITE_LLM,
instruction="You answer only math questions")
physics_agent = LlmAgent(name="Physics",
description="Handles physics question",
model=MODEL_GPT_4O_LITE_LLM,
instruction="You answer only physics questions")
coordinator = LlmAgent(
name="TutorCoordinator",
model=MODEL_GPT_4O_LITE_LLM,
instruction="Route user requests: Use Math agent for math questions, physics agent for physics questions.",
description="Main tutor router.",
# allow_transfer=True is often implicit with sub_agents in AutoFlow
sub_agents=[math_agent, physics_agent]
)
# parent_agent = coordinator.parent_agent
parent_agent = coordinator.root_agent
print("Parent Agent is ", parent_agent)
sub_agents = coordinator.sub_agents
print("Sub agents are ", sub_agents)
Metadata
Metadata
Assignees
Labels
core[Component] This issue is related to the core interface and implementation[Component] This issue is related to the core interface and implementationquestion[Component] This issue is asking a question or clarification[Component] This issue is asking a question or clarification