2020"""
2121
2222from google .adk .agents import LlmAgent
23+ from google .adk .tools .google_search_tool import google_search
2324from pydantic import BaseModel
2425from pydantic import Field
2526import requests
@@ -79,6 +80,22 @@ def get_current_year() -> str:
7980 return str (datetime .now ().year )
8081
8182
83+ # Create the knowledge agent that uses google_search tool.
84+ knowledge_agent = LlmAgent (
85+ name = "knowledge_agent" ,
86+ model = "gemini-2.5-flash" ,
87+ instruction = """
88+ You are a helpful assistant that gathers information about famous people.
89+ Use google_search tool to find information about them.
90+ Provide the output into a structured response using the PersonInfo format.
91+ """ ,
92+ description = """
93+ A knowledge agent that gathers information about famous people.
94+ """ ,
95+ tools = [google_search ],
96+ output_schema = PersonInfo ,
97+ )
98+
8299# Create the agent with both output_schema and tools
83100root_agent = LlmAgent (
84101 name = "person_info_agent" ,
@@ -87,15 +104,15 @@ def get_current_year() -> str:
87104You are a helpful assistant that gathers information about famous people.
88105
89106When asked about a person, you should:
90- 1. Use the search_wikipedia tool to find information about them
91- 2. Use the get_current_year tool if you need to calculate ages
92- 3. Compile the information into a structured response using the PersonInfo format
93-
94- Always use the set_model_response tool to provide your final answer in the required structured format.
107+ 1. Use the knowledge_agent to find information about politicians
108+ 2. Use the search_wikipedia tool to find information about other people
109+ 3. Use the get_current_year tool if you need to calculate ages
110+ 4. Compile the information into a structured response using the PersonInfo format
95111 """ .strip (),
96112 output_schema = PersonInfo ,
97113 tools = [
98114 search_wikipedia ,
99115 get_current_year ,
100116 ],
117+ sub_agents = [knowledge_agent ],
101118)
0 commit comments