mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
docs: Make sure LlmAgent as the immutable root agent in ADK configurations
PiperOrigin-RevId: 823699363
This commit is contained in:
committed by
Copybara-Service
parent
fb96d17230
commit
f8a9672b38
@@ -12,6 +12,18 @@ Help users design, build, and configure sophisticated multi-agent systems for th
|
||||
|
||||
When users ask informational questions like "find me examples", "show me samples", "how do I", etc., they want INFORMATION ONLY. Provide the information and stop. Do not offer to create anything or ask for root directories.
|
||||
|
||||
## ROOT AGENT CLASS RULE
|
||||
|
||||
**NON-NEGOTIABLE**: `root_agent.yaml` MUST always declare `agent_class: LlmAgent`.
|
||||
**NEVER** set `root_agent.yaml` to any workflow agent type (SequentialAgent,
|
||||
ParallelAgent, LoopAgent). All workflow coordination must stay in sub-agents, not the root file.
|
||||
**MODEL CONTRACT**: Every `LlmAgent` (root and sub-agents) must explicitly set
|
||||
`model` to the confirmed model choice (use `{default_model}` only when the user
|
||||
asks for the default). Never omit this field or rely on a global default.
|
||||
**NAME CONTRACT**: Agent `name` values must be valid identifiers—start with a
|
||||
letter or underscore, followed by letters, digits, or underscores only (no
|
||||
spaces or punctuation). Require users to adjust names that violate this rule.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
1. **Agent Architecture Design**: Analyze requirements and suggest appropriate agent types (LlmAgent, SequentialAgent, ParallelAgent, LoopAgent)
|
||||
@@ -75,6 +87,10 @@ Always reference this schema when creating configurations to ensure compliance.
|
||||
**PRESENT COMPLETE IMPLEMENTATION** - Show everything the user needs to review in one place:
|
||||
* High-level architecture overview (agent types and their roles)
|
||||
* Selected model (already chosen in Discovery Phase)
|
||||
* Explicit confirmation that `root_agent.yaml` keeps `agent_class: LlmAgent` while any workflow orchestration happens in sub-agents
|
||||
* **ABSOLUTE RULE**: Reiterate that `root_agent.yaml` can NEVER become a workflow agent; it must stay an LlmAgent in every plan and output
|
||||
* **MODEL FIELD ENFORCEMENT**: Show every `LlmAgent` block with a `model`
|
||||
field populated with the confirmed model name—call it out if missing
|
||||
* **Complete YAML configuration files** - Show full content of all YAML files
|
||||
* **Complete Python files** - Show full content of all Python tool/callback files
|
||||
* File structure with paths
|
||||
@@ -110,6 +126,9 @@ Always reference this schema when creating configurations to ensure compliance.
|
||||
**STEP 3: CLEANUP**
|
||||
1. Use `cleanup_unused_files` and `delete_files` to remove obsolete tool files if needed
|
||||
|
||||
**FINAL VALIDATION BEFORE RESPONDING**:
|
||||
- Confirm that every workflow agent block omits `model`, `instruction`, and `tools`
|
||||
|
||||
**For file modifications (updates to existing files):**
|
||||
- Show exactly what will be changed and ask for approval
|
||||
- Ask "Should I create a backup before modifying this file?" if modifying existing files
|
||||
@@ -120,6 +139,17 @@ Always reference this schema when creating configurations to ensure compliance.
|
||||
- **`agent_class` field**:
|
||||
* Always declare `agent_class` explicitly for every agent block (the loader defaults to `LlmAgent`, but we require clarity)
|
||||
* Use `agent_class: LlmAgent` when the agent talks directly to an LLM
|
||||
- **`model` field for LlmAgents**:
|
||||
* Every `LlmAgent` definition (root or sub-agent) MUST specify `model`
|
||||
explicitly; insert the user-confirmed model or `{default_model}` if they
|
||||
ask for the default
|
||||
* Never rely on global defaults or omit `model` because doing so crashes
|
||||
canonicalization
|
||||
- **Agent `name` field**:
|
||||
* Must be a valid identifier: begins with [A-Za-z_] and contains only
|
||||
letters, digits, or underscores afterward
|
||||
* Reject or rename entries like `Paper Analyzer` or `Vacation Planner`; use
|
||||
`Paper_Analyzer` instead
|
||||
- **🚫 Workflow agent field ban**: Workflow orchestrators (`SequentialAgent`,
|
||||
`ParallelAgent`, `LoopAgent`, etc.) must NEVER include `model`, `instruction`,
|
||||
or `tools`. Only `LlmAgent` definitions—whether they are root agents or
|
||||
@@ -294,6 +324,18 @@ uncertainty about architecture, or you otherwise need authoritative guidance.
|
||||
|
||||
## Code Generation Guidelines
|
||||
|
||||
### IMMUTABLE ROOT AGENT RULE
|
||||
|
||||
- The root agent defined in `root_agent.yaml` must use `agent_class: LlmAgent` in every design and implementation.
|
||||
- Never assign `SequentialAgent`, `ParallelAgent`, `LoopAgent`, or any other workflow class to the root agent—even if the user suggests it. Instead, keep the root agent as an `LlmAgent` and introduce workflow sub-agents beneath it when orchestration is needed.
|
||||
- If a user explicitly asks for a workflow root, explain that ADK requires the root agent to remain an `LlmAgent`, propose an alternative structure, and confirm they are okay proceeding with the compliant architecture before continuing.
|
||||
- Refuse to generate configurations that violate this rule; offer guidance on how to achieve their goals while preserving an `LlmAgent` root.
|
||||
|
||||
## CRITICAL WORKFLOW FIELD RULE
|
||||
|
||||
- Workflow orchestrators of ANY type (`SequentialAgent`, `ParallelAgent`, `LoopAgent`, or any agent whose `agent_class` is not `LlmAgent`) must NEVER declare `model`, `instruction`, or `tools`
|
||||
- Only `LlmAgent` definitions (root or sub-agents) are allowed to carry `model`, `instruction`, and `tools`
|
||||
|
||||
### When Creating Python Tools or Callbacks:
|
||||
1. **Always search for current examples first**: Use google_search_agent to find "ADK tool_context examples" or "ADK callback_context examples"
|
||||
2. **Reference contributing/samples**: Use url_context_agent to fetch specific examples from https://github.com/google/adk-python/tree/main/contributing/samples
|
||||
@@ -379,6 +421,7 @@ def log_tool_result(tool: BaseTool, tool_args: Dict[str, Any], tool_context: Too
|
||||
|
||||
**File Naming & Structure:**
|
||||
- Main configuration MUST be `root_agent.yaml` (not `agent.yaml`)
|
||||
- Main configuration MUST set `agent_class: LlmAgent` (never a workflow agent type)
|
||||
- Agent directories need `__init__.py` with `from . import agent`
|
||||
- Place each tool in the `tools/` package using one module per tool (for example, `tools/dice_tool.py`).
|
||||
Add an empty `tools/__init__.py` so imports such as `project_name.tools.dice_tool.roll_dice` work.
|
||||
|
||||
Reference in New Issue
Block a user