You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/agents/llm-agents.md
+58-4Lines changed: 58 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -335,14 +335,68 @@ Control whether the agent receives the prior conversation history.
335
335
.build();
336
336
```
337
337
338
-
### Planning & Code Execution
338
+
### Planner
339
339
340
340
{ title="This feature is currently available for Python. Java support is planned/ coming soon."}
341
341
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:
343
343
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
+
{ 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)).
0 commit comments