Skip to content

Commit 45a96f5

Browse files
authored
Merge branch 'google:main' into feat/openai-responses-api-3209
2 parents 651e17d + aa51512 commit 45a96f5

55 files changed

Lines changed: 2276 additions & 223 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
name: adk-issue
3+
description: Analyze and triage GitHub issues for the adk-python repository. Use this skill when the user provides an issue number or link to investigate whether the issue is legitimate, whether it should be fixed, and if there is an existing PR addressing it. Triggers on "analyze issue", "issue #", "github issue", "github.com/google/adk-python/issues/".
4+
---
5+
6+
# ADK Issue Analyzer & Triager
7+
8+
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.
9+
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.
16+
17+
## Phase 1: Triage and Analysis (Read-Only)
18+
19+
### Step 1: Retrieve and Parse the Issue
20+
1. **Extract the issue number**: Parse the number from the link or prompt (e.g., `https://github.com/google/adk-python/issues/5882` -> `5882`).
21+
2. **Fetch issue details**: Use the `gh` CLI tool to fetch issue details in JSON format:
22+
```bash
23+
gh issue view <issue_number> --repo google/adk-python --json number,title,body,state,labels,comments,assignees,createdAt,closedAt
24+
```
25+
*If the `gh` CLI is not available or errors out, use `read_url_content` to fetch the public GitHub issue page:*
26+
```
27+
https://github.com/google/adk-python/issues/<issue_number>
28+
```
29+
30+
---
31+
32+
### Step 2: Deep Investigation & Analysis
33+
Address the following four critical questions and present your findings in a structured, premium report.
34+
35+
#### 1. What is broken?
36+
Explain the root cause of the issue or failure:
37+
- **Trace the execution flow**: Identify which components, classes, or functions are malfunctioning.
38+
- **Pinpoint the bug**: Detail why the system is behaving incorrectly and where the failure originates (e.g. incorrect logic, missing configuration, unhandled states).
39+
40+
#### 2. Is the issue legitimate?
41+
Inspect the codebase to confirm if the issue represents a real problem:
42+
- **Examine the description**: Identify the component, class, function, or file referenced.
43+
- **Search the codebase**: Use `grep_search` to locate the relevant files/functions in the local workspace.
44+
- **Inspect the code**: Open the files using `view_file` to analyze the code's current logic.
45+
- **Verify the bug**:
46+
- Is the reported problem actually present in the code?
47+
- Does it produce the reported error or behavior under the current version (ADK 2.0)?
48+
- Is it a documentation typo, setup discrepancy, or a genuine code/logic bug?
49+
- **Document your code evidence**: Reference specific file paths and line ranges (using clickable markdown file links, e.g., `[skill_toolset.py](file:///path/to/file#L123)`) in your report.
50+
51+
#### 3. Should we fix it?
52+
Formulate a recommendation on whether the issue should be addressed:
53+
- **Assess the impact**:
54+
- Does it break core functionality?
55+
- Does it affect standard developer workflows or introduce brittle workarounds?
56+
- Is it a high-priority bug or a low-impact cosmetic/feature request?
57+
- **Check alignment**:
58+
- Does the suggested solution align with `adk-architecture` and `adk-style`?
59+
- Is it consistent with Python idioms and Pydantic validation rules?
60+
- **Evaluate workarounds**: Is there a clean workaround, or is a core fix necessary?
61+
- **Final Recommendation**: Clearly declare whether we should fix it, along with the reasoning and estimated complexity/scope of the fix.
62+
63+
#### 4. Is there a linked PR that fixes this issue?
64+
Search for any existing pull requests that attempt to resolve the issue:
65+
- **Search PRs**: Run `gh pr list --repo google/adk-python --search "<issue_number>"` to list pull requests mentioning the issue number in the branch name, title, or body.
66+
- **Verify the PR details**: If PRs are found, fetch their details:
67+
```bash
68+
gh pr view <pr_number> --repo google/adk-python --json number,title,state,url,body,author
69+
```
70+
- **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.
72+
- **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.)"
73+
74+
---
75+
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:
80+
- **Do NOT commit the changes**: Leave them uncommitted in the workspace so the user can review and iterate on them.
81+
- **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:
82+
```bash
83+
git checkout -b fix/<issue_number>-<desc> origin/main
84+
```
85+
- **Follow these implementation steps**:
86+
1. **Create the fix**: Modify the necessary source files implementing clean, robust logic following `adk-style` and `adk-architecture`.
87+
2. **Add or update unittests**: Write comprehensive unit tests to verify the behavior and prevent regressions.
88+
3. **Update documentation**: Update `/docs/design` and `/docs/guides` if applicable to the changes.
89+
4. **Update samples**: Update `/contributing/samples` if applicable to demonstrate the new capability or updated behavior.
90+
91+
---
92+
93+
## Report Template
94+
95+
Present your final analysis as a high-quality markdown response using the following structure:
96+
97+
```markdown
98+
# GitHub Issue #<issue_number> Analysis: <Issue Title>
99+
100+
## Detailed Analysis
101+
102+
### 1. Root Cause Analysis ("What is broken?")
103+
- Explanation of the failure or bug (what is failing and why).
104+
- Pinpoint the exact file, function, or design component that is malfunctioning.
105+
106+
### 2. Legitimacy Analysis
107+
- **Status**: [Legitimate Bug / Feature Request / Duplicate / Invalid / Not Reproducible]
108+
- **Evidence**:
109+
- Code references: [filename.py](file:///absolute/path/to/file#L100-L120)
110+
- Analysis of code behavior and why the issue occurs.
111+
112+
### 3. Fix Recommendation
113+
- **Recommendation**: [Should Fix (High Priority) / Should Fix (Medium/Low Priority) / Won't Fix / Needs Discussion]
114+
- **Rationale**:
115+
- Impact on user experience, workflows, or architecture.
116+
- Implementation complexity and risk of side effects.
117+
118+
### 4. Existing Pull Requests
119+
- **Linked PR**: [None / Pull Request #<pr_number> - <PR Title> (<state>)]
120+
- **PR URL**: <PR URL>
121+
- **Analysis**: Brief summary of the PR's approach and status (e.g., "Fixes the bug by implementing X in Y, currently awaiting review").
122+
123+
---
124+
125+
## Executive Summary
126+
1. **What is broken?** [Brief explanation of the root cause or error]
127+
2. **Is the issue legitimate?** [Yes / No - brief explanation]
128+
3. **Should we fix it?** [Yes / No / Needs Discussion - priority & brief reasoning]
129+
4. **Is there a linked PR that fixes this issue?** [None / Yes, PR #<pr_number> - <state>]
130+
```
131+
132+
---
133+
134+
## Tips & Best Practices
135+
> [!TIP]
136+
> Always use explicit repository qualifiers (`--repo google/adk-python`) when running `gh` commands to avoid failures due to custom internal or local git remotes.
137+
138+
> [!IMPORTANT]
139+
> When presenting code files and lines, always use markdown file links that point directly to the files in the workspace. Make sure the link is clickable and formatted as `[filename.py](file:///absolute/path/to/file#L100-L120)` without surrounding backticks around the brackets.

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

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ 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.
1721

1822
## Project Overview
1923

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Abort Agent Sample
2+
3+
## Overview
4+
5+
This sample demonstrates a standalone ADK agent designed specifically to showcase cooperative task cancellation on client disconnections.
6+
7+
The agent leverages a custom tool that counts from 1 to a target number requested by the user, pausing 1 second between each count and printing the progress directly to the server's stdout terminal. This delay allows you to easily trigger connection drops (by cancelling client requests mid-execution) and visually observe that background agent execution halts immediately in the server terminal, resolving resource leaks.
8+
9+
## Sample Inputs
10+
11+
- `Count to 10 seconds`
12+
13+
The agent will call the `count_seconds` tool with a target count of 10, pausing 1 second between each increment.
14+
15+
- `Please count up to 20`
16+
17+
The agent will invoke the tool to count to 20. If you close the client connection (such as pressing `Ctrl+C` in a cURL window or closing your browser tab) while the loop is running, counting halts immediately.
18+
19+
## Graph
20+
21+
```mermaid
22+
graph TD
23+
START --> AbortAgent
24+
AbortAgent --> |"Invoke Tool"| count_seconds
25+
count_seconds --> |"Abort if Disconnected / Done"| AbortAgent
26+
AbortAgent --> ANSWER
27+
```
28+
29+
## How To
30+
31+
### 1. Running Locally via the CLI
32+
33+
To interact with the agent in your local shell terminal:
34+
35+
```bash
36+
adk run contributing/samples/core/abort/
37+
```
38+
39+
Type `count to 10` at the `[user]:` prompt. Pressing `Ctrl+C` mid-run will abort counting and exit.
40+
41+
### 2. Running via HTTP Server and cURL
42+
43+
To verify connection-drop abortion over network protocols (e.g. simple HTTP REST request):
44+
45+
1. Start the local development server to watch the sample workspace:
46+
```bash
47+
adk web --allow_origins=http://localhost:4200 contributing/samples/
48+
```
49+
1. In a separate terminal, register the test session (local CLI development servers run with `--auto_create_session` set to `False` by default):
50+
```bash
51+
curl -X POST http://localhost:8000/apps/abort_agent/users/user/sessions \
52+
-H "Content-Type: application/json" \
53+
-d '{"session_id": "8b24e6ed-1fff-4f0c-a06a-e065692a446e"}'
54+
```
55+
1. Initiate the count request (this blocks waiting for a response):
56+
```bash
57+
curl -X POST http://localhost:8000/run \
58+
-H "Content-Type: application/json" \
59+
-d '{
60+
"app_name": "abort_agent",
61+
"user_id": "user",
62+
"session_id": "8b24e6ed-1fff-4f0c-a06a-e065692a446e",
63+
"new_message": {
64+
"role": "user",
65+
"parts": [{"text": "count to 100"}]
66+
}
67+
}'
68+
```
69+
1. Observe your `adk web` terminal window. You will see the counting progress logging.
70+
1. **Trigger the Abort**: Press `Ctrl+C` in your cURL terminal window to close the client connection.
71+
1. Observe the server console window. Counting halts instantly and prints:
72+
```text
73+
[Counting Tool] Count was ABORTED mid-run at progress: X/100 (Client Disconnected)!
74+
```
75+
76+
### 3. Running and Testing via ADK Web (Dev UI)
77+
78+
To observe cooperative aborts interactively in the web-based developer interface:
79+
80+
1. Start the local development server:
81+
```bash
82+
adk web --allow_origins=http://localhost:4200 contributing/samples/
83+
```
84+
1. Open the ADK Web interface (`http://localhost:4200`) in your web browser.
85+
1. Select the **`abort_agent`** app from the left sidebar panel.
86+
1. Type `count to 100` in the message input box and click submit.
87+
1. **Trigger the Abort**: Simply close your browser tab, refresh the page, or navigate away from the chat panel.
88+
1. Observe the server's stdout terminal console. You will see that counting halts immediately and logs:
89+
```text
90+
[Counting Tool] Count was ABORTED mid-run (Client Disconnected)!
91+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from . import agent

0 commit comments

Comments
 (0)