Skip to content

Commit 2155a35

Browse files
xuanyang15copybara-github
authored andcommitted
docs: Update ADK release analyzer to use Gemini 3 Pro with retry and improve file filtering
Co-authored-by: Xuan Yang <xygoogle@google.com> PiperOrigin-RevId: 861784867
1 parent 3bcd8f7 commit 2155a35

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

contributing/samples/adk_documentation/adk_release_analyzer/agent.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,25 @@
5757
from google.adk.agents.loop_agent import LoopAgent
5858
from google.adk.agents.readonly_context import ReadonlyContext
5959
from google.adk.agents.sequential_agent import SequentialAgent
60+
from google.adk.models import Gemini
6061
from google.adk.tools.exit_loop_tool import exit_loop
6162
from google.adk.tools.tool_context import ToolContext
63+
from google.genai import types
64+
65+
# Retry configuration for handling API rate limits and overload
66+
_RETRY_OPTIONS = types.HttpRetryOptions(
67+
initial_delay=10,
68+
attempts=8,
69+
exp_base=2,
70+
max_delay=300,
71+
http_status_codes=[429, 503],
72+
)
73+
74+
# Use gemini-3-pro-preview for planning and summary (better quality)
75+
GEMINI_PRO_WITH_RETRY = Gemini(
76+
model="gemini-3-pro-preview",
77+
retry_options=_RETRY_OPTIONS,
78+
)
6279

6380
# Maximum number of files per analysis group to avoid context overflow
6481
MAX_FILES_PER_GROUP = 5
@@ -249,7 +266,7 @@ def get_release_context(tool_context: ToolContext) -> dict[str, Any]:
249266
# =============================================================================
250267

251268
planner_agent = Agent(
252-
model="gemini-2.5-pro",
269+
model=GEMINI_PRO_WITH_RETRY,
253270
name="release_planner",
254271
description=(
255272
"Plans the analysis by fetching release info and organizing files into"
@@ -272,12 +289,12 @@ def get_release_context(tool_context: ToolContext) -> dict[str, Any]:
272289
273290
3. Call `get_changed_files_summary` to get the list of changed files WITHOUT
274291
the full patches (to save context space).
275-
- **IMPORTANT**: Pass `local_repo_path="{LOCAL_REPOS_DIR_PATH}/{CODE_REPO}"`
276-
to use local git and avoid GitHub API's 300-file limit.
292+
- **IMPORTANT**: Pass these parameters:
293+
- `local_repo_path="{LOCAL_REPOS_DIR_PATH}/{CODE_REPO}"` to avoid 300-file limit
294+
- `path_filter="src/google/adk/"` to only get ADK source files (reduces token usage)
277295
278-
4. Filter and organize the files:
279-
- **INCLUDE** only files in `src/google/adk/` directory
280-
- **EXCLUDE** test files, `__init__.py`, and files outside src/
296+
4. Further filter the returned files:
297+
- **EXCLUDE** test files and `__init__.py` files
281298
- **IMPORTANT**: Do NOT exclude any file just because it has few changes.
282299
Even single-line changes to public APIs need documentation updates.
283300
- **PRIORITIZE** by importance:
@@ -423,7 +440,7 @@ def file_analyzer_instruction(readonly_context: ReadonlyContext) -> str:
423440

424441

425442
file_group_analyzer = Agent(
426-
model="gemini-2.5-pro",
443+
model=GEMINI_PRO_WITH_RETRY,
427444
name="file_group_analyzer",
428445
description=(
429446
"Analyzes a group of changed files and generates recommendations."
@@ -507,7 +524,7 @@ def summary_instruction(readonly_context: ReadonlyContext) -> str:
507524

508525

509526
summary_agent = Agent(
510-
model="gemini-2.5-pro",
527+
model=GEMINI_PRO_WITH_RETRY,
511528
name="summary_agent",
512529
description="Compiles recommendations and creates the GitHub issue.",
513530
instruction=summary_instruction,
@@ -542,7 +559,7 @@ def summary_instruction(readonly_context: ReadonlyContext) -> str:
542559
# =============================================================================
543560

544561
root_agent = Agent(
545-
model="gemini-2.5-pro",
562+
model=GEMINI_PRO_WITH_RETRY,
546563
name="adk_release_analyzer",
547564
description=(
548565
"Analyzes ADK Python releases and generates documentation update"

contributing/samples/adk_documentation/tools.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ def get_changed_files_summary(
605605
start_tag: str,
606606
end_tag: str,
607607
local_repo_path: Optional[str] = None,
608+
path_filter: Optional[str] = None,
608609
) -> Dict[str, Any]:
609610
"""Gets a summary of changed files between two releases without patches.
610611
@@ -620,14 +621,17 @@ def get_changed_files_summary(
620621
local_repo_path: Optional absolute path to local git repo. If provided
621622
and valid, uses git diff instead of GitHub API to get complete
622623
file list (avoids 300-file limit).
624+
path_filter: Optional path prefix to filter files. Only files whose
625+
path starts with this prefix will be included. Example:
626+
"src/google/adk/" to only include ADK source files.
623627
624628
Returns:
625629
A dictionary containing the status and a summary of changed files.
626630
"""
627631
# Use local git if valid path is provided (avoids GitHub API 300-file limit)
628632
if local_repo_path and os.path.isdir(os.path.join(local_repo_path, ".git")):
629633
return _get_changed_files_from_local_git(
630-
local_repo_path, start_tag, end_tag, repo_owner, repo_name
634+
local_repo_path, start_tag, end_tag, repo_owner, repo_name, path_filter
631635
)
632636

633637
# Fall back to GitHub API (limited to 300 files)
@@ -689,6 +693,7 @@ def _get_changed_files_from_local_git(
689693
end_tag: str,
690694
repo_owner: str,
691695
repo_name: str,
696+
path_filter: Optional[str] = None,
692697
) -> Dict[str, Any]:
693698
"""Gets changed files using local git commands (no file limit).
694699
@@ -698,6 +703,7 @@ def _get_changed_files_from_local_git(
698703
end_tag: The newer tag (head) for the comparison.
699704
repo_owner: Repository owner for compare URL.
700705
repo_name: Repository name for compare URL.
706+
path_filter: Optional path prefix to filter files.
701707
702708
Returns:
703709
A dictionary containing the status and a summary of changed files.
@@ -766,6 +772,10 @@ def _get_changed_files_from_local_git(
766772
status_code = parts[0][0] # First char is the status
767773
filename = parts[-1] # Last part is filename (handles renames)
768774

775+
# Apply path filter if specified
776+
if path_filter and not filename.startswith(path_filter):
777+
continue
778+
769779
stats = file_stats.get(
770780
filename,
771781
{

src/google/adk/cli/cli_tools_click.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,6 @@ def cli_eval(
701701
separated list of eval names and then add that as a suffix to the eval set
702702
file name, demarcated by a `:`.
703703
704-
\b
705704
For example, we have `sample_eval_set_file.json` file that has following the
706705
eval cases:
707706
sample_eval_set_file.json:
@@ -722,7 +721,6 @@ def cli_eval(
722721
separated list of eval names and then add that as a suffix to the eval set
723722
file name, demarcated by a `:`.
724723
725-
\b
726724
For example, we have `sample_eval_set_id` that has following the eval cases:
727725
sample_eval_set_id:
728726
|....... eval_1
@@ -731,7 +729,6 @@ def cli_eval(
731729
|....... eval_4
732730
|....... eval_5
733731
734-
\b
735732
If we did:
736733
sample_eval_set_id:eval_1,eval_2,eval_3
737734

0 commit comments

Comments
 (0)