Skip to content

Commit 38cd9d6

Browse files
Merge branch 'google:main' into add-agent-registry-support
2 parents 6e88953 + ae95a97 commit 38cd9d6

37 files changed

Lines changed: 1439 additions & 163 deletions

.agents/skills/adk-issue/SKILL.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ description: Analyze and triage GitHub issues for the adk-python repository. Use
77

88
This skill provides a structured workflow for analyzing, verifying, and triaging GitHub issues from the `google/adk-python` repository. When a user provides a GitHub issue number or link, use this skill to perform deep investigation and report your findings.
99

10-
## Issue Triage Workflow
10+
> [!IMPORTANT]
11+
> ## CRITICAL EXECUTION RULE: STOP AFTER STEP 2
12+
> * **Phase 1 (Triage & Report) is strictly read-only**: Do NOT modify any code, create new branches, or write any implementation in your first response.
13+
> * **STOP and ask**: You must present the analysis report first and explicitly ask the user:
14+
> > "Would you like me to create and implement a fix for this issue in the workspace? (Note: The changes and tests will be created in a new branch but NOT committed, so you can review and iterate on them.)"
15+
> * **Wait for Approval**: Only proceed with Phase 2 (Step 3: Implementation) in a subsequent turn *after* the user explicitly approves the recommendation.
1116
12-
Follow this 3-step process to analyze the issue:
17+
## Phase 1: Triage and Analysis (Read-Only)
1318

1419
### Step 1: Retrieve and Parse the Issue
1520
1. **Extract the issue number**: Parse the number from the link or prompt (e.g., `https://github.com/google/adk-python/issues/5882` -> `5882`).
@@ -63,13 +68,15 @@ Search for any existing pull requests that attempt to resolve the issue:
6368
gh pr view <pr_number> --repo google/adk-python --json number,title,state,url,body,author
6469
```
6570
- **Analyze progress**: Check if the PR is open, merged, or closed, and if it successfully fixes the issue according to the repository's testing patterns.
71+
- **Present the structured report**: Format and present your findings structured as a premium report following the **Report Template** below.
6672
- **Offer to create a fix**: If no existing PR is found, you MUST explicitly ask the user: "Would you like me to create and implement a fix for this issue in the workspace? (Note: The changes and tests will be created in a new branch but NOT committed, so you can review and iterate on them.)"
6773

6874
---
6975

70-
### Step 3: Report & Propose Fix
71-
1. **Present the structured report**: Follow the **Report Template** below to format your findings.
72-
2. **Propose a fix**: If there is no existing PR addressing the issue, explicitly ask the user if they would like you to implement the fix in the workspace. When implementing the fix:
76+
## Phase 2: Implementation (After User Approval)
77+
78+
### Step 3: Propose and Implement Fix
79+
Once the user has approved the implementation of the fix in the workspace, follow these rules:
7380
- **Do NOT commit the changes**: Leave them uncommitted in the workspace so the user can review and iterate on them.
7481
- **Base the branch on remote HEAD**: When creating the new branch, ensure it is based on the remote tracking branch HEAD (`origin/main`), not the current local branch. For example:
7582
```bash

.agents/skills/adk-pr-triage/SKILL.md

Lines changed: 302 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
"""Helper script for ADK PR Triage verification and remote update."""
17+
18+
from __future__ import annotations
19+
20+
import argparse
21+
import json
22+
import subprocess
23+
import sys
24+
25+
26+
def run_command(args: list[str]) -> tuple[int, str, str]:
27+
"""Runs a shell command and returns its exit code, stdout, and stderr."""
28+
try:
29+
res = subprocess.run(args, capture_output=True, text=True, check=False)
30+
return res.returncode, res.stdout.strip(), res.stderr.strip()
31+
except Exception as e:
32+
return -1, "", str(e)
33+
34+
35+
def verify_cla(pr_number: str) -> bool:
36+
"""Verifies if the Google CLA is signed for the given PR number."""
37+
print(f"[*] Fetching status checks for PR #{pr_number}...")
38+
cmd = [
39+
"gh",
40+
"pr",
41+
"view",
42+
pr_number,
43+
"--repo",
44+
"google/adk-python",
45+
"--json",
46+
"statusCheckRollup",
47+
]
48+
code, stdout, stderr = run_command(cmd)
49+
if code != 0:
50+
print(
51+
f"Error: Failed to fetch PR details from GitHub: {stderr}",
52+
file=sys.stderr,
53+
)
54+
sys.exit(1)
55+
56+
try:
57+
data = json.loads(stdout)
58+
except json.JSONDecodeError:
59+
print("Error: Failed to parse GitHub API JSON response.", file=sys.stderr)
60+
sys.exit(1)
61+
62+
status_checks = data.get("statusCheckRollup", [])
63+
cla_check = None
64+
for check in status_checks:
65+
if check.get("name") == "cla/google":
66+
cla_check = check
67+
break
68+
69+
if not cla_check:
70+
print("\n" + "=" * 80)
71+
print("🚨 CRITICAL COMPLIANCE REFUSAL: GOOGLE CLA NOT SIGNED/VERIFIED 🚨")
72+
print("=" * 80)
73+
print(
74+
"Error: The mandatory 'cla/google' status check is completely missing"
75+
" on GitHub."
76+
)
77+
print(
78+
"The contributor HAS NOT signed the Google Contributor License"
79+
" Agreement."
80+
)
81+
print(
82+
"Legal policy strictly prohibits triaging, downloading, or reviewing"
83+
" this PR."
84+
)
85+
print("=" * 80 + "\n")
86+
return False
87+
88+
conclusion = cla_check.get("conclusion")
89+
if conclusion != "SUCCESS":
90+
print("\n" + "=" * 80)
91+
print("🚨 CRITICAL COMPLIANCE REFUSAL: GOOGLE CLA NOT SIGNED/VERIFIED 🚨")
92+
print("=" * 80)
93+
print(
94+
"Error: The 'cla/google' status check has the status:"
95+
f" '{conclusion or 'UNKNOWN'}'."
96+
)
97+
print(
98+
"The contributor HAS NOT successfully signed or verified the Google"
99+
" CLA."
100+
)
101+
print(
102+
"Legal policy strictly prohibits triaging, downloading, or reviewing"
103+
" this PR."
104+
)
105+
print("=" * 80 + "\n")
106+
return False
107+
108+
print("✅ Google CLA is verified and signed (status SUCCESS).")
109+
return True
110+
111+
112+
def update_pr_branch(pr_number: str) -> None:
113+
"""Updates the remote PR branch with the latest changes from the base branch."""
114+
print(
115+
f"\n[*] Attempting to update PR #{pr_number} branch via remote REBASE..."
116+
)
117+
rebase_cmd = [
118+
"gh",
119+
"pr",
120+
"update-branch",
121+
pr_number,
122+
"--rebase",
123+
"--repo",
124+
"google/adk-python",
125+
]
126+
code, stdout, stderr = run_command(rebase_cmd)
127+
if code == 0:
128+
print(
129+
"✅ Successfully updated PR branch on GitHub by rebasing onto base"
130+
" branch!"
131+
)
132+
if stdout:
133+
print(stdout)
134+
return
135+
136+
print(f"Warning: Remote rebase-update failed: {stderr}")
137+
print("[*] Falling back to standard remote MERGE commit update...")
138+
139+
merge_cmd = [
140+
"gh",
141+
"pr",
142+
"update-branch",
143+
pr_number,
144+
"--repo",
145+
"google/adk-python",
146+
]
147+
code, stdout, stderr = run_command(merge_cmd)
148+
if code == 0:
149+
print(
150+
"✅ Successfully updated PR branch on GitHub via standard merge commit!"
151+
)
152+
if stdout:
153+
print(stdout)
154+
return
155+
156+
print(
157+
"\n[!] Warning: Remote branch update failed completely on GitHub server:"
158+
f" {stderr}"
159+
)
160+
print(" This is typical if edits are disabled on the contributor's fork.")
161+
print(
162+
" No worries! We will automatically rebase locally after checking out."
163+
)
164+
165+
166+
def main() -> None:
167+
parser = argparse.ArgumentParser(
168+
description="Triage PR verification and sync helper."
169+
)
170+
parser.add_argument(
171+
"pr_number", help="The GitHub Pull Request number (e.g. 5875)."
172+
)
173+
parser.add_argument(
174+
"--skip-update",
175+
action="store_true",
176+
help="Skip updating the remote PR branch on GitHub.",
177+
)
178+
args = parser.parse_args()
179+
180+
# Step 1: Verify CLA
181+
if not verify_cla(args.pr_number):
182+
sys.exit(2) # Exit code 2 indicates compliance refusal
183+
184+
# Step 2: Update branch
185+
if not args.skip_update:
186+
update_pr_branch(args.pr_number)
187+
188+
print("\n[*] Verification complete. Safe to proceed with checkout.")
189+
sys.exit(0)
190+
191+
192+
if __name__ == "__main__":
193+
main()

.agents/skills/adk-review/SKILL.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
name: adk-review
3+
description: Reviews all local changes in the repository for errors, styling compliance, unintended outcomes, and necessary documentation/test/sample updates. Generates a report and assists in fixing identified issues on-demand. Triggers on "adk-review", "review changes", "pr review", "check code style", "verify changes".
4+
---
5+
6+
# ADK Change Reviewer (adk-review)
7+
8+
This skill guides AI assistants in performing a comprehensive, rigorous review of local repository changes before they are committed or submitted. It evaluates code correctness, style guidelines, architectural impact, and checks if associated tests, samples, and documentation need updates. It generates a detailed report and, upon explicit user request, assists in automatically fixing the identified issues.
9+
10+
> [!NOTE]
11+
> Always read this skill and follow its steps when asked to review local changes or before finalizing a PR/commit.
12+
13+
---
14+
15+
## Review Checklist Dimensions
16+
17+
### 1. Code Correctness & Errors
18+
- **Syntax & Types**: Ensure the code is free of syntax errors and conforms to strong typing guidelines. Avoid using `Any`, and prefer specific/abstract types. Use `X | None` instead of `Optional[X]`.
19+
- **Imports**: Verify there are no circular imports. Ensure absolute imports are used where appropriate.
20+
- **Exception Handling**: Avoid bare `except:`. Always catch specific exceptions and log them properly with context.
21+
- **Visibility**: Ensure internal modules and package-private attributes use proper naming (e.g., prefixed with `_`) per ADK rules.
22+
- **Edge Cases & Defensive Programming**:
23+
- **Type & Attribute Discrimination**: Explicitly verify an object's type (e.g., using `isinstance`) before checking type-specific or custom attributes (e.g., checking if a node is an `LlmAgent` before inspecting its `mode`), avoiding errors on unexpected types.
24+
- **Boundary and Null Conditions**: Ensure robust handling for boundary conditions and null values (e.g., `None`, empty collections, zero, or empty strings) using validation or fallback defaults.
25+
- **Preconditions & Invariants**: Validate that preconditions and state invariants are checked before performing core logic.
26+
27+
### 2. Style and Convention Compliance
28+
- **ADK Style Guide**: Cross-reference all code changes with the guidelines in the `adk-style` skill (including Pydantic v2 patterns, lazy logging evaluation, and file structure).
29+
- **Pre-commit Hooks**: Ensure changed files are formatted and linted. Remind the user to run `pre-commit run --files <files>` if hooks like `isort`, `pyink`, `addlicense`, or `mdformat` are not configured automatically.
30+
31+
### 3. Architectural Integrity & Unintended Outcomes
32+
- **Public API Stability**: Verify whether changes modify, remove, or restrict public-facing interfaces, classes, methods, argument lists, or CLI structures (e.g., in the public package namespaces under `src/google/adk/`). Breaking changes are unacceptable without a formal deprecation cycle under Semantic Versioning.
33+
- **Execution & Resumption**: If changing workflows, nodes, or state management, ensure compatibility with the ADK 2.0 event execution lifecycle and session resumption (HITL/checkpoints).
34+
- **Concurrency & Safety**: Check for race conditions or resource leaks. Ensure long-running or shared resources (like plugins, exporters, and connections) are closed/disposed of safely.
35+
36+
### 4. Documentation Impact (`docs/design` and `docs/guides`)
37+
- **Design & Architecture**: Determine if the change updates a core design contract. If so, check if design docs under `docs/design/` require updates or new documents need to be written.
38+
- **Guides**: If the changes introduce a new feature or change a public API/workflow pattern, check if the guides under `docs/guides/` need updates.
39+
40+
### 5. Sample Compatibility & Updates
41+
- **Sample Integrity**: Verify if existing samples under `contributing/samples/` are affected by the change.
42+
- **New Samples**: If the changes introduce a key new capability, assess whether a new sample should be added to demonstrate the feature (following `adk-sample-creator` conventions).
43+
44+
### 6. Test Coverage & Quality
45+
- **Coverage**: Ensure that all modified or new code paths have corresponding unit or integration tests under `tests/`.
46+
- **ADK Test Rules**: Ensure test implementations adhere to the 9 rules in the `adk-style` testing reference (e.g., using deterministic IDs, event normalization, and clean up utilities).
47+
48+
---
49+
50+
## Execution Workflow
51+
52+
When the `adk-review` skill is triggered, you MUST execute the following steps:
53+
54+
### Step 1: Retrieve Local Changes
55+
Run `git status` and `git diff` to identify exactly which files have been modified, added, or deleted.
56+
57+
### Step 2: Perform the Multi-Dimensional Review
58+
Analyze the retrieved diffs file-by-file against the six dimensions in the Checklist. Identify any errors, deviations, or missing files (such as docs, tests, or samples).
59+
60+
### Step 3: Generate and Present a Review Report
61+
Generate a clear, beautifully formatted Markdown report categorized by priority:
62+
- 🔴 **Critical Errors / Bugs**: Syntax, type safety violations, race conditions, or resource leaks.
63+
- 🟡 **Style & Conventions**: Lints, formatting issues, non-lazy logging, or typing mismatches.
64+
- 🔵 **Documentation, Tests, & Samples**: Missing or stale test coverage, design docs, or user guides.
65+
66+
Include the specific filename and line number/context for each finding.
67+
68+
### Step 4: Present Findings and Stop
69+
Stop execution here. Do **NOT** call any code editing tools or modify the codebase automatically. Present the generated review report clearly to the user, highlighting key takeaways, and stop.
70+
71+
Do **NOT** ask the user if they want you to fix the issues, and do **NOT** offer interactive fixing options by default. Simply stop and wait for the user to explicitly command or ask you to fix the changes.
72+
73+
### Step 5 (Optional): Implement Authorized Fixes & Verify
74+
If, and only if, the user explicitly instructs or requests you to apply a fix for some or all of the identified findings:
75+
1. Perform the necessary edits using precise code editing tools. Ensure all fixes strictly comply with the established `adk-style` and `adk-architecture` rules.
76+
2. Verify correctness by running associated unit and integration tests (e.g., via `pytest` or pre-commit hooks) before concluding.

.github/workflows/copybara-pr-handler.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ jobs:
5757
console.log(`\n--- Processing commit ${sha.substring(0, 7)} ---`);
5858
console.log(`Committer: ${committer}`);
5959
60-
// Check if this is a Copybara commit
60+
// Check if this is a Copybara commit or has a pull request reference
6161
const isCopybara = committer === 'Copybara-Service' ||
6262
commit.author?.email === 'genai-sdk-bot@google.com' ||
6363
message.includes('GitOrigin-RevId:') ||
64-
message.includes('PiperOrigin-RevId:');
64+
message.includes('PiperOrigin-RevId:') ||
65+
/Merge:?\s+https:\/\/github\.com\/google\/adk-python\/pull\/(\d+)/.test(message);
6566
6667
if (!isCopybara) {
6768
console.log('Not a Copybara commit, skipping');
@@ -118,6 +119,14 @@ jobs:
118119
body: `Thank you @${author} for your contribution! 🎉\n\nYour changes have been successfully imported and merged via Copybara in commit ${commitSha}.\n\nClosing this PR as the changes are now in the main branch.`
119120
});
120121
122+
// Add 'merged' label to the PR
123+
await github.rest.issues.addLabels({
124+
owner: context.repo.owner,
125+
repo: context.repo.repo,
126+
issue_number: prNumber,
127+
labels: ['merged']
128+
});
129+
121130
// Close the PR
122131
await github.rest.pulls.update({
123132
owner: context.repo.owner,

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ For all matters regarding ADK development, please use the appropriate skill:
1414
- Read `.agents/skills/adk-git/SKILL.md` for full instructions.
1515
- **`adk-sample-creator`**: Use this skill when creating new samples demonstrating features or agent patterns, or when adding examples to subdirectories under `contributing/`.
1616
- Read `.agents/skills/adk-sample-creator/SKILL.md` for full instructions.
17+
- **`adk-review`**: Use this skill to review local changes for errors, style compliance, unintended outcomes, and to check if associated design docs, guides, samples, or tests need updates.
18+
- Read `.agents/skills/adk-review/SKILL.md` for full instructions.
19+
- **`adk-issue`**: Use this skill when analyzing and triaging GitHub issues for the adk-python repository to verify legitimacy, recommend fixes, and check for existing PRs.
20+
- Read `.agents/skills/adk-issue/SKILL.md` for full instructions.
21+
- **`adk-pr-triage`**: Use this skill when triaging and analyzing GitHub pull requests (PRs) to evaluate their objectives, legitimacy, value, and alignment with ADK's architectural, styling, and testing principles.
22+
- Read `.agents/skills/adk-pr-triage/SKILL.md` for full instructions.
23+
1724

1825
## Project Overview
1926

contributing/samples/models/interactions_api/agent.py

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

15-
"""Agent definition for testing the Interactions API integration.
16-
"""
15+
"""Agent definition for testing the Interactions API integration."""
1716

1817
from google.adk.agents.llm_agent import Agent
1918
from google.adk.models.google_llm import Gemini

0 commit comments

Comments
 (0)