Skip to content

Commit a86cff7

Browse files
feat(planner): add BuiltInPlanner and PlanReActPlanner to docs (#491)
* feat(planner): add BuiltInPlanner and PlanReActPlanner to docs * add an example output --------- Co-authored-by: Lavi Nigam <[email protected]>
1 parent b40accd commit a86cff7

File tree

1 file changed

+58
-4
lines changed

1 file changed

+58
-4
lines changed

docs/agents/llm-agents.md

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,68 @@ Control whether the agent receives the prior conversation history.
335335
.build();
336336
```
337337

338-
### Planning & Code Execution
338+
### Planner
339339

340340
![python_only](https://img.shields.io/badge/Currently_supported_in-Python-blue){ title="This feature is currently available for Python. Java support is planned/ coming soon."}
341341

342-
For more complex reasoning involving multiple steps or executing code:
342+
**`planner` (Optional):** Assign a `BasePlanner` instance to enable multi-step reasoning and planning before execution. There are two main planners:
343343

344-
* **`planner` (Optional):** Assign a `BasePlanner` instance to enable multi-step reasoning and planning before execution. (See [Multi-Agents](multi-agents.md) patterns).
345-
* **`code_executor` (Optional):** Provide a `BaseCodeExecutor` instance to allow the agent to execute code blocks (e.g., Python) found in the LLM's response. ([See Tools/Built-in tools](../tools/built-in-tools.md)).
344+
* **`BuiltInPlanner`:** Leverages the model's built-in planning capabilities (e.g., Gemini's thinking feature). See [Gemini Thinking](https://ai.google.dev/gemini-api/docs/thinking) for details and examples.
345+
346+
Here, the `thinking_budget` parameter guides the model on the number of thinking tokens to use when generating a response. The `include_thoughts` parameter controls whether the model should include its raw thoughts and internal reasoning process in the response.
347+
348+
```python
349+
from google.adk import Agent
350+
from google.adk.planners import BuiltInPlanner
351+
from google.genai import types
352+
353+
my_agent = Agent(
354+
model="gemini-2.5-flash",
355+
planner=BuiltInPlanner(
356+
thinking_config=types.ThinkingConfig(
357+
include_thoughts=True,
358+
thinking_budget=1024,
359+
)
360+
),
361+
# ... your tools here
362+
)
363+
```
364+
365+
* **`PlanReActPlanner`:** This planner instructs the model to follow a specific structure in its output: first create a plan, then execute actions (like calling tools), and provide reasoning for its steps. *It's particularly useful for models that don't have a built-in "thinking" feature*.
366+
367+
```python
368+
from google.adk import Agent
369+
from google.adk.planners import PlanReActPlanner
370+
371+
my_agent = Agent(
372+
model="gemini-2.0-flash",
373+
planner=PlanReActPlanner(),
374+
# ... your tools here
375+
)
376+
```
377+
378+
The agent's response will follow a structured format:
379+
380+
```
381+
[user]: ai news
382+
[google_search_agent]: /*PLANNING*/
383+
1. Perform a Google search for "latest AI news" to get current updates and headlines related to artificial intelligence.
384+
2. Synthesize the information from the search results to provide a summary of recent AI news.
385+
386+
/*ACTION*/
387+
/*REASONING*/
388+
The search results provide a comprehensive overview of recent AI news, covering various aspects like company developments, research breakthroughs, and applications. I have enough information to answer the user's request.
389+
390+
/*FINAL_ANSWER*/
391+
Here's a summary of recent AI news:
392+
....
393+
```
394+
395+
### Code Execution
396+
397+
![python_only](https://img.shields.io/badge/Currently_supported_in-Python-blue){ title="This feature is currently available for Python. Java support is planned/ coming soon."}
398+
399+
* **`code_executor` (Optional):** Provide a `BaseCodeExecutor` instance to allow the agent to execute code blocks found in the LLM's response. ([See Tools/Built-in tools](../tools/built-in-tools.md)).
346400

347401
## Putting It Together: Example
348402

0 commit comments

Comments
 (0)