Skip to content

Commit 0f71ce1

Browse files
authored
Merge branch 'main' into fix_message_parts_order
2 parents a7f01bc + e0e5384 commit 0f71ce1

File tree

17 files changed

+744
-200
lines changed

17 files changed

+744
-200
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ We welcome contributions from the community! Whether it's bug reports, feature r
155155

156156
If you are to develop agent via vibe coding the [llms.txt](./llms.txt) and the [llms-full.txt](./llms-full.txt) can be used as context to LLM. While the former one is a summarized one and the later one has the full information in case your LLM has big enough context window.
157157

158+
## Community Events
159+
160+
- [Completed] ADK's 1st community meeting on Wednesday, October 15, 2025. Remember to [join our group](https://groups.google.com/g/adk-community) to get access to the [recording](https://drive.google.com/file/d/1rpXDq5NSH8-MyMeYI6_5pZ3Lhn0X9BQf/view), and [deck](https://docs.google.com/presentation/d/1_b8LG4xaiadbUUDzyNiapSFyxanc9ZgFdw7JQ6zmZ9Q/edit?slide=id.g384e60cdaca_0_658&resourcekey=0-tjFFv0VBQhpXBPCkZr0NOg#slide=id.g384e60cdaca_0_658).
161+
158162
## 📄 License
159163

160164
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.

contributing/samples/adk_agent_builder_assistant/instruction_embedded.template

Lines changed: 68 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ Help users design, build, and configure sophisticated multi-agent systems for th
1212

1313
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.
1414

15+
## ROOT AGENT CLASS RULE
16+
17+
**NON-NEGOTIABLE**: `root_agent.yaml` MUST always declare `agent_class: LlmAgent`.
18+
**NEVER** set `root_agent.yaml` to any workflow agent type (SequentialAgent,
19+
ParallelAgent, LoopAgent). All workflow coordination must stay in sub-agents, not the root file.
20+
**MODEL CONTRACT**: Every `LlmAgent` (root and sub-agents) must explicitly set
21+
`model` to the confirmed model choice (use `{default_model}` only when the user
22+
asks for the default). Never omit this field or rely on a global default.
23+
**NAME CONTRACT**: Agent `name` values must be valid identifiers—start with a
24+
letter or underscore, followed by letters, digits, or underscores only (no
25+
spaces or punctuation). Require users to adjust names that violate this rule.
26+
1527
## Core Capabilities
1628

1729
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.
7587
**PRESENT COMPLETE IMPLEMENTATION** - Show everything the user needs to review in one place:
7688
* High-level architecture overview (agent types and their roles)
7789
* Selected model (already chosen in Discovery Phase)
90+
* Explicit confirmation that `root_agent.yaml` keeps `agent_class: LlmAgent` while any workflow orchestration happens in sub-agents
91+
* **ABSOLUTE RULE**: Reiterate that `root_agent.yaml` can NEVER become a workflow agent; it must stay an LlmAgent in every plan and output
92+
* **MODEL FIELD ENFORCEMENT**: Show every `LlmAgent` block with a `model`
93+
field populated with the confirmed model name—call it out if missing
7894
* **Complete YAML configuration files** - Show full content of all YAML files
7995
* **Complete Python files** - Show full content of all Python tool/callback files
8096
* File structure with paths
@@ -110,6 +126,9 @@ Always reference this schema when creating configurations to ensure compliance.
110126
**STEP 3: CLEANUP**
111127
1. Use `cleanup_unused_files` and `delete_files` to remove obsolete tool files if needed
112128

129+
**FINAL VALIDATION BEFORE RESPONDING**:
130+
- Confirm that every workflow agent block omits `model`, `instruction`, and `tools`
131+
113132
**For file modifications (updates to existing files):**
114133
- Show exactly what will be changed and ask for approval
115134
- Ask "Should I create a backup before modifying this file?" if modifying existing files
@@ -120,6 +139,23 @@ Always reference this schema when creating configurations to ensure compliance.
120139
- **`agent_class` field**:
121140
* Always declare `agent_class` explicitly for every agent block (the loader defaults to `LlmAgent`, but we require clarity)
122141
* Use `agent_class: LlmAgent` when the agent talks directly to an LLM
142+
- **`model` field for LlmAgents**:
143+
* Every `LlmAgent` definition (root or sub-agent) MUST specify `model`
144+
explicitly; insert the user-confirmed model or `{default_model}` if they
145+
ask for the default
146+
* Never rely on global defaults or omit `model` because doing so crashes
147+
canonicalization
148+
- **Agent `name` field**:
149+
* Must be a valid identifier: begins with [A-Za-z_] and contains only
150+
letters, digits, or underscores afterward
151+
* Reject or rename entries like `Paper Analyzer` or `Vacation Planner`; use
152+
`Paper_Analyzer` instead
153+
- **🚫 Workflow agent field ban**: Workflow orchestrators (`SequentialAgent`,
154+
`ParallelAgent`, `LoopAgent`, etc.) must NEVER include `model`, `instruction`,
155+
or `tools`. Only `LlmAgent` definitions—whether they are root agents or
156+
sub-agents—may declare those fields
157+
- **Root agent requirement**: The root configuration must always remain an
158+
`LlmAgent`. Never convert the root agent into a workflow agent.
123159
- **Workflow agent tool rule**: See **ADK Agent Types and Model Field Rules** for tool restrictions on workflow orchestrators; attach tools to their `LlmAgent` sub-agents.
124160
- **Sub-agent placement**: Place ALL sub-agent YAML files in the main project folder, NOT in `sub_agents/` subfolder
125161
- Tool paths use format: `project_name.tools.module.function_name` (must start with project folder name, no `.py` extension, all dots)
@@ -236,44 +272,25 @@ tools:
236272

237273
### ADK Knowledge and Research Tools
238274

239-
#### Remote Semantic Search
240-
- **adk_knowledge_agent**: Search ADK knowledge base for ADK examples, patterns, and documentation
241-
242-
#### Web-based Research
243-
- **google_search_agent**: Search web for ADK examples, patterns, and documentation (returns full page content as results)
244-
- **url_context_agent**: Fetch content from specific URLs when mentioned in search results or user queries (use only when specific URLs need additional fetching)
245-
246-
#### Local ADK Source Search
247-
- **search_adk_source**: Search ADK source code using regex patterns for precise code lookups
248-
* Use for finding class definitions: `"class FunctionTool"`
249-
* Use for constructor signatures: `"def __init__.*FunctionTool"`
250-
* Use for method definitions: `"def method_name"`
251-
* Returns matches with file paths, line numbers, and context
252-
* Follow up with **read_files** to get complete file contents
253-
254-
**Research Workflow for ADK Questions:**
255-
Mainly rely on **adk_knowledge_agent** for ADK questions. Use other tools only when the knowledge agent doesn't have enough information.
256-
257-
1. **search_adk_source** - Find specific code patterns with regex
258-
2. **read_files** - Read complete source files for detailed analysis
259-
3. **google_search_agent** - Find external examples and documentation
260-
4. **url_context_agent** - Fetch specific GitHub files or documentation pages
261-
262-
### When to Use Research Tools
263-
**ALWAYS use research tools when:**
264-
1. **User asks ADK questions**: Any questions about ADK concepts, APIs, usage patterns, or troubleshooting
265-
2. **Unfamiliar ADK features**: When user requests features you're not certain about
266-
3. **Agent type clarification**: When unsure about agent types, their capabilities, or configuration
267-
4. **Best practices**: When user asks for examples or best practices
268-
5. **Error troubleshooting**: When helping debug ADK-related issues
269-
6. **Agent building uncertainty**: When unsure how to create agents or what's the best practice
270-
7. **Architecture decisions**: When evaluating different approaches or patterns for agent design
271-
272-
**Research Tool Usage Patterns:**
273-
274-
**Default Research Tool:**
275-
Use **adk_knowledge_agent** as the primary research tool for ADK questions.
276-
Use other tools only when the knowledge agent doesn't have enough information.
275+
**Default research tool**: Use `adk_knowledge_agent` first for ADK concepts, APIs,
276+
examples, and troubleshooting. Switch to the tools below only when the
277+
knowledge agent lacks the needed information.
278+
279+
- `search_adk_source`: Regex search across ADK source for classes, methods, and
280+
signatures; follow up with `read_files` for full context.
281+
- `google_search_agent`: Broader web search for ADK-related examples or docs.
282+
- `url_context_agent`: Fetch content from specific URLs returned by search
283+
results.
284+
285+
**Trigger research when** users ask ADK questions, request unfamiliar features,
286+
need agent-type clarification, want best practices, hit errors, express
287+
uncertainty about architecture, or you otherwise need authoritative guidance.
288+
289+
**Recommended research sequence** (stop once you have enough information):
290+
1. `adk_knowledge_agent`
291+
2. `search_adk_source` → `read_files`
292+
3. `google_search_agent`
293+
4. `url_context_agent`
277294

278295
**For ADK Code Questions (NEW - Preferred Method):**
279296
1. **search_adk_source** - Find exact code patterns:
@@ -307,6 +324,18 @@ Use other tools only when the knowledge agent doesn't have enough information.
307324

308325
## Code Generation Guidelines
309326

327+
### IMMUTABLE ROOT AGENT RULE
328+
329+
- The root agent defined in `root_agent.yaml` must use `agent_class: LlmAgent` in every design and implementation.
330+
- 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.
331+
- 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.
332+
- Refuse to generate configurations that violate this rule; offer guidance on how to achieve their goals while preserving an `LlmAgent` root.
333+
334+
## CRITICAL WORKFLOW FIELD RULE
335+
336+
- Workflow orchestrators of ANY type (`SequentialAgent`, `ParallelAgent`, `LoopAgent`, or any agent whose `agent_class` is not `LlmAgent`) must NEVER declare `model`, `instruction`, or `tools`
337+
- Only `LlmAgent` definitions (root or sub-agents) are allowed to carry `model`, `instruction`, and `tools`
338+
310339
### When Creating Python Tools or Callbacks:
311340
1. **Always search for current examples first**: Use google_search_agent to find "ADK tool_context examples" or "ADK callback_context examples"
312341
2. **Reference contributing/samples**: Use url_context_agent to fetch specific examples from https://github.com/google/adk-python/tree/main/contributing/samples
@@ -392,6 +421,7 @@ def log_tool_result(tool: BaseTool, tool_args: Dict[str, Any], tool_context: Too
392421

393422
**File Naming & Structure:**
394423
- Main configuration MUST be `root_agent.yaml` (not `agent.yaml`)
424+
- Main configuration MUST set `agent_class: LlmAgent` (never a workflow agent type)
395425
- Agent directories need `__init__.py` with `from . import agent`
396426
- Place each tool in the `tools/` package using one module per tool (for example, `tools/dice_tool.py`).
397427
Add an empty `tools/__init__.py` so imports such as `project_name.tools.dice_tool.roll_dice` work.

contributing/samples/adk_pr_triaging_agent/agent.py

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
from google.adk import Agent
2828
import requests
2929

30-
LABEL_TO_OWNER = {
31-
"documentation": "polong-lin",
32-
"services": "DeanChensj",
33-
"tools": "seanzhou1023",
34-
"mcp": "seanzhou1023",
35-
"eval": "ankursharmas",
36-
"live": "hangfei",
37-
"models": "genquan9",
38-
"tracing": "Jacksunwei",
39-
"core": "Jacksunwei",
40-
"web": "wyf7107",
41-
}
30+
ALLOWED_LABELS = [
31+
"documentation",
32+
"services",
33+
"tools",
34+
"mcp",
35+
"eval",
36+
"live",
37+
"models",
38+
"tracing",
39+
"core",
40+
"web",
41+
]
4242

4343
CONTRIBUTING_MD = read_file(
4444
Path(__file__).resolve().parents[3] / "CONTRIBUTING.md"
@@ -158,19 +158,19 @@ def get_pull_request_details(pr_number: int) -> str:
158158
return error_response(str(e))
159159

160160

161-
def add_label_and_reviewer_to_pr(pr_number: int, label: str) -> dict[str, Any]:
162-
"""Adds a specified label and requests a review from a mapped reviewer on a PR.
161+
def add_label_to_pr(pr_number: int, label: str) -> dict[str, Any]:
162+
"""Adds a specified label on a pull request.
163163
164164
Args:
165165
pr_number: the number of the Github pull request
166166
label: the label to add
167167
168168
Returns:
169-
The the status of this request, with the applied label and assigned
170-
reviewer when successful.
169+
The the status of this request, with the applied label and response when
170+
successful.
171171
"""
172-
print(f"Attempting to add label '{label}' and a reviewer to PR #{pr_number}")
173-
if label not in LABEL_TO_OWNER:
172+
print(f"Attempting to add label '{label}' to PR #{pr_number}")
173+
if label not in ALLOWED_LABELS:
174174
return error_response(
175175
f"Error: Label '{label}' is not an allowed label. Will not apply."
176176
)
@@ -186,31 +186,10 @@ def add_label_and_reviewer_to_pr(pr_number: int, label: str) -> dict[str, Any]:
186186
except requests.exceptions.RequestException as e:
187187
return error_response(f"Error: {e}")
188188

189-
owner = LABEL_TO_OWNER.get(label, None)
190-
if not owner:
191-
return {
192-
"status": "warning",
193-
"message": (
194-
f"{response}\n\nLabel '{label}' does not have an owner. Will not"
195-
" assign."
196-
),
197-
"applied_label": label,
198-
}
199-
reviewer_url = f"{GITHUB_BASE_URL}/repos/{OWNER}/{REPO}/pulls/{pr_number}/requested_reviewers"
200-
reviewer_payload = {"reviewers": [owner]}
201-
try:
202-
post_request(reviewer_url, reviewer_payload)
203-
except requests.exceptions.RequestException as e:
204-
return {
205-
"status": "warning",
206-
"message": f"Reviewer not assigned: {e}",
207-
"applied_label": label,
208-
}
209-
210189
return {
211190
"status": "success",
212191
"applied_label": label,
213-
"assigned_reviewer": owner,
192+
"response": response,
214193
}
215194

216195

@@ -252,7 +231,6 @@ def add_comment_to_pr(pr_number: int, comment: str) -> dict[str, Any]:
252231
Your core responsibility includes:
253232
- Get the pull request details.
254233
- Add a label to the pull request.
255-
- Assign a reviewer to the pull request.
256234
- Check if the pull request is following the contribution guidelines.
257235
- Add a comment to the pull request if it's not following the guidelines.
258236
@@ -303,7 +281,7 @@ def add_comment_to_pr(pr_number: int, comment: str) -> dict[str, Any]:
303281
- Skip the PR (i.e. do not label or comment) if any of the following is true:
304282
- the PR is closed
305283
- the PR is labeled with "google-contributior"
306-
- the PR is already labelled with the above labels (e.g. "documentation", "services", "tools", etc.) and has a reviewer assigned.
284+
- the PR is already labelled with the above labels (e.g. "documentation", "services", "tools", etc.).
307285
- Check if the PR is following the contribution guidelines.
308286
- If it's not following the guidelines, recommend or add a comment to the PR that points to the contribution guidelines (https://github.com/google/adk-python/blob/main/CONTRIBUTING.md).
309287
- If it's following the guidelines, recommend or add a label to the PR.
@@ -312,12 +290,11 @@ def add_comment_to_pr(pr_number: int, comment: str) -> dict[str, Any]:
312290
Present the followings in an easy to read format highlighting PR number and your label.
313291
- The PR summary in a few sentence
314292
- The label you recommended or added with the justification
315-
- The owner of the label if you assigned a reviewer to the PR
316293
- The comment you recommended or added to the PR with the justification
317294
""",
318295
tools=[
319296
get_pull_request_details,
320-
add_label_and_reviewer_to_pr,
297+
add_label_to_pr,
321298
add_comment_to_pr,
322299
],
323300
)

contributing/samples/computer_use/agent.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,32 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
16+
import tempfile
17+
1518
from google.adk import Agent
16-
from google.adk.models.google_llm import Gemini
1719
from google.adk.tools.computer_use.computer_use_toolset import ComputerUseToolset
18-
from typing_extensions import override
1920

2021
from .playwright import PlaywrightComputer
2122

23+
# Define user_data_dir path
24+
profile_name = 'browser_profile_for_adk'
25+
profile_path = os.path.join(tempfile.gettempdir(), profile_name)
26+
os.makedirs(profile_path, exist_ok=True)
27+
28+
computer_with_profile = PlaywrightComputer(
29+
screen_size=(1280, 936),
30+
user_data_dir=profile_path,
31+
)
32+
33+
# Create agent with the toolset using the new computer instance
2234
root_agent = Agent(
2335
model='gemini-2.5-computer-use-preview-10-2025',
2436
name='hello_world_agent',
2537
description=(
2638
'computer use agent that can operate a browser on a computer to finish'
2739
' user tasks'
2840
),
29-
instruction="""
30-
you are a computer use agent
31-
""",
32-
tools=[
33-
ComputerUseToolset(computer=PlaywrightComputer(screen_size=(1280, 936)))
34-
],
41+
instruction=""" you are a computer use agent """,
42+
tools=[ComputerUseToolset(computer=computer_with_profile)],
3543
)

0 commit comments

Comments
 (0)