-
|
Suppose you create: root_agent = LlmAgent(..., planner=PlanReActPlanner(), tools=[fetch_more_information], ...)And the tool is: def fetch_more_information(...):
""" Always use this tool to get more information before refining a plan.
Unfortunately you have to plan->use this tool->refine plan for it to work.
"""
return info_for_decision_makingCan the planner access the tool? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Yes, the planner will come up with a plan that may use the tool if needed. |
Beta Was this translation helpful? Give feedback.
-
|
No — the planner and the agent executor are separate phases in the ADK lifecycle, and tools are only available during the execution phase, not the planning phase. Here is how it works:
Workaround: Two-Phase PatternIf you need information before planning, use a sequential agent pattern: from google.adk.agents import SequentialAgent, LlmAgent
# Phase 1: Gather info (has tools, no planner)
info_agent = LlmAgent(
name="InfoGatherer",
model="gemini-2.0-flash",
tools=[fetch_more_information],
instruction="Use the tool to gather information, then summarize findings.",
)
# Phase 2: Plan and execute with the gathered context
planner_agent = LlmAgent(
name="Planner",
model="gemini-2.0-flash",
planner=PlanReActPlanner(),
tools=[your_other_tools],
instruction="Use the context from InfoGatherer to create and execute a plan.",
)
root_agent = SequentialAgent(
name="Root",
sub_agents=[info_agent, planner_agent],
)This way the info-gathering happens first, its output becomes part of the session context, and the planner agent can use that context when creating its plan. Alternative: ReAct without PlannerIf you want the agent to interleave thinking and tool use naturally, you can skip the planner entirely. The default agent = LlmAgent(
name="ReactAgent",
model="gemini-2.0-flash",
tools=[fetch_more_information, other_tools],
instruction="First use fetch_more_information, then reason about the results.",
)TL;DR: Planners cannot access tools. Use a |
Beta Was this translation helpful? Give feedback.
Yes, the planner will come up with a plan that may use the tool if needed.