Skip to content

Commit 18432d0

Browse files
committed
Merge main into feature/support-single-agent-transcription
2 parents c646e95 + 955632c commit 18432d0

File tree

311 files changed

+30568
-9401
lines changed

Some content is hidden

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

311 files changed

+30568
-9401
lines changed

.github/pull_request_template.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
**Please ensure you have read the [contribution guide](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) before creating a pull request.**
2+
3+
### Link to Issue or Description of Change
4+
5+
**1. Link to an existing issue (if applicable):**
6+
7+
- Closes: #_issue_number_
8+
- Related: #_issue_number_
9+
10+
**2. Or, if no issue exists, describe the change:**
11+
12+
_If applicable, please follow the issue templates to provide as much detail as
13+
possible._
14+
15+
**Problem:**
16+
_A clear and concise description of what the problem is._
17+
18+
**Solution:**
19+
_A clear and concise description of what you want to happen and why you choose
20+
this solution._
21+
22+
### Testing Plan
23+
24+
_Please describe the tests that you ran to verify your changes. This is required
25+
for all PRs that are not small documentation or typo fixes._
26+
27+
**Unit Tests:**
28+
29+
- [ ] I have added or updated unit tests for my change.
30+
- [ ] All unit tests pass locally.
31+
32+
_Please include a summary of passed `pytest` results._
33+
34+
**Manual End-to-End (E2E) Tests:**
35+
36+
_Please provide instructions on how to manually test your changes, including any
37+
necessary setup or configuration. Please provide logs or screenshots to help
38+
reviewers better understand the fix._
39+
40+
### Checklist
41+
42+
- [ ] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
43+
- [ ] I have performed a self-review of my own code.
44+
- [ ] I have commented my code, particularly in hard-to-understand areas.
45+
- [ ] I have added tests that prove my fix is effective or that my feature works.
46+
- [ ] New and existing unit tests pass locally with my changes.
47+
- [ ] I have manually tested my changes end-to-end.
48+
- [ ] Any dependent changes have been merged and published in downstream modules.
49+
50+
### Additional context
51+
52+
_Add any other context or screenshots about the feature request here._

.github/workflows/pr-triage.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ name: ADK Pull Request Triaging Agent
33
on:
44
pull_request_target:
55
types: [opened, reopened, edited]
6+
workflow_dispatch:
7+
inputs:
8+
pr_number:
9+
description: 'The Pull Request number to triage'
10+
required: true
11+
type: 'string'
612

713
jobs:
814
agent-triage-pull-request:
9-
if: "!contains(github.event.pull_request.labels.*.name, 'bot triaged') && !contains(github.event.pull_request.labels.*.name, 'google-contributor')"
15+
if: github.event_name == 'workflow_dispatch' || !contains(github.event.pull_request.labels.*.name, 'google-contributor')
1016
runs-on: ubuntu-latest
1117
permissions:
1218
pull-requests: write
@@ -33,7 +39,7 @@ jobs:
3339
GOOGLE_GENAI_USE_VERTEXAI: 0
3440
OWNER: 'google'
3541
REPO: 'adk-python'
36-
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
42+
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number || github.event.inputs.pr_number }}
3743
INTERACTIVE: ${{ vars.PR_TRIAGE_INTERACTIVE }}
3844
PYTHONPATH: contributing/samples
3945
run: python -m adk_pr_triaging_agent.main

.github/workflows/triage.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: ADK Issue Triaging Agent
33
on:
44
issues:
55
types: [opened, reopened]
6-
schedule:
7-
- cron: '0 */6 * * *' # every 6h
86

97
jobs:
108
agent-triage-issues:

CHANGELOG.md

Lines changed: 212 additions & 4 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ information on using pull requests.
5757
### Requirement for PRs
5858

5959
- All PRs, other than small documentation or typo fixes, should have a Issue
60-
associated. If not, please create one.
60+
associated. If a relevant issue doesn't exist, please create one first or
61+
you may instead describe the bug or feature directly within the PR
62+
description, following the structure of our issue templates.
6163
- Small, focused PRs. Keep changes minimal—one concern per PR.
6264
- For bug fixes or features, please provide logs or screenshot after the fix
6365
is applied to help reviewers better understand the fix.

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424

2525
Agent Development Kit (ADK) is a flexible and modular framework for developing and deploying AI agents. While optimized for Gemini and the Google ecosystem, ADK is model-agnostic, deployment-agnostic, and is built for compatibility with other frameworks. ADK was designed to make agent development feel more like software development, to make it easier for developers to create, deploy, and orchestrate agentic architectures that range from simple tasks to complex workflows.
2626

27-
2827
---
2928

3029
## 🔥 What's new
3130

32-
- **Agent Config**: Build agents without code. Check out the
33-
[Agent Config](https://google.github.io/adk-docs/agents/config/) feature.
31+
- **Custom Service Registration**: Add a service registry to provide a generic way to register custom service implementations to be used in FastAPI server. See short instruction [here](https://github.com/google/adk-python/discussions/3175#discussioncomment-14745120). ([391628f](https://github.com/google/adk-python/commit/391628fcdc7b950c6835f64ae3ccab197163c990))
32+
33+
- **Rewind**: Add the ability to rewind a session to before a previous invocation ([9dce06f](https://github.com/google/adk-python/commit/9dce06f9b00259ec42241df4f6638955e783a9d1)).
3434

35-
- **Tool Confirmation**: A [tool confirmation flow(HITL)](https://google.github.io/adk-docs/tools/confirmation/) that can guard tool execution with explicit confirmation and custom input
35+
- **New CodeExecutor**: Introduces a new AgentEngineSandboxCodeExecutor class that supports executing agent-generated code using the Vertex AI Code Execution Sandbox API ([ee39a89](https://github.com/google/adk-python/commit/ee39a891106316b790621795b5cc529e89815a98))
3636

3737
## ✨ Key Features
3838

@@ -43,6 +43,11 @@ Agent Development Kit (ADK) is a flexible and modular framework for developing a
4343
- **Code-First Development**: Define agent logic, tools, and orchestration
4444
directly in Python for ultimate flexibility, testability, and versioning.
4545

46+
- **Agent Config**: Build agents without code. Check out the
47+
[Agent Config](https://google.github.io/adk-docs/agents/config/) feature.
48+
49+
- **Tool Confirmation**: A [tool confirmation flow(HITL)](https://google.github.io/adk-docs/tools/confirmation/) that can guard tool execution with explicit confirmation and custom input.
50+
4651
- **Modular Multi-Agent Systems**: Design scalable applications by composing
4752
multiple specialized agents into flexible hierarchies.
4853

contributing/samples/adk_agent_builder_assistant/agent_builder_assistant.py

Lines changed: 43 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@
2424
from google.adk.models import BaseLlm
2525
from google.adk.tools import AgentTool
2626
from google.adk.tools import FunctionTool
27+
from google.genai import types
2728

29+
from .sub_agents.adk_knowledge_agent import create_adk_knowledge_agent
2830
from .sub_agents.google_search_agent import create_google_search_agent
2931
from .sub_agents.url_context_agent import create_url_context_agent
3032
from .tools.cleanup_unused_files import cleanup_unused_files
3133
from .tools.delete_files import delete_files
3234
from .tools.explore_project import explore_project
3335
from .tools.read_config_files import read_config_files
3436
from .tools.read_files import read_files
35-
from .tools.resolve_root_directory import resolve_root_directory
3637
from .tools.search_adk_source import search_adk_source
3738
from .tools.write_config_files import write_config_files
3839
from .tools.write_files import write_files
@@ -58,9 +59,7 @@ def create_agent(
5859
Configured LlmAgent with embedded ADK AgentConfig schema
5960
"""
6061
# Load full ADK AgentConfig schema directly into instruction context
61-
instruction = AgentBuilderAssistant._load_instruction_with_schema(
62-
model, working_directory
63-
)
62+
instruction = AgentBuilderAssistant._load_instruction_with_schema(model)
6463

6564
# TOOL ARCHITECTURE: Hybrid approach using both AgentTools and FunctionTools
6665
#
@@ -70,9 +69,14 @@ def create_agent(
7069
# - Maintains compatibility with existing ADK tool ecosystem
7170

7271
# Built-in ADK tools wrapped as sub-agents
72+
adk_knowledge_agent = create_adk_knowledge_agent()
7373
google_search_agent = create_google_search_agent()
7474
url_context_agent = create_url_context_agent()
75-
agent_tools = [AgentTool(google_search_agent), AgentTool(url_context_agent)]
75+
agent_tools = [
76+
AgentTool(adk_knowledge_agent),
77+
AgentTool(google_search_agent),
78+
AgentTool(url_context_agent),
79+
]
7680

7781
# CUSTOM FUNCTION TOOLS: Agent Builder specific capabilities
7882
#
@@ -88,8 +92,6 @@ def create_agent(
8892
write_config_files
8993
), # Write/validate multiple YAML configs
9094
FunctionTool(explore_project), # Analyze project structure
91-
# Working directory context tools
92-
FunctionTool(resolve_root_directory),
9395
# File management tools (multi-file support)
9496
FunctionTool(read_files), # Read multiple files
9597
FunctionTool(write_files), # Write multiple files
@@ -112,6 +114,9 @@ def create_agent(
112114
instruction=instruction,
113115
model=model,
114116
tools=all_tools,
117+
generate_content_config=types.GenerateContentConfig(
118+
max_output_tokens=8192,
119+
),
115120
)
116121

117122
return agent
@@ -125,7 +130,6 @@ def _load_schema() -> str:
125130
# ADK AgentConfig schema loading with caching and error handling.
126131
schema_content = load_agent_config_schema(
127132
raw_format=True, # Get as JSON string
128-
escape_braces=True, # Escape braces for template embedding
129133
)
130134

131135
# Format as indented code block for instruction embedding
@@ -147,7 +151,6 @@ def _load_schema() -> str:
147151
@staticmethod
148152
def _load_instruction_with_schema(
149153
model: Union[str, BaseLlm],
150-
working_directory: Optional[str] = None,
151154
) -> Callable[[ReadonlyContext], str]:
152155
"""Load instruction template and embed ADK AgentConfig schema content."""
153156
instruction_template = (
@@ -162,19 +165,43 @@ def _load_instruction_with_schema(
162165
else getattr(model, "model_name", str(model))
163166
)
164167

165-
# Fill the instruction template with ADK AgentConfig schema content and default model
166-
instruction_text = instruction_template.format(
167-
schema_content=schema_content, default_model=model_str
168-
)
169-
170168
# Return a function that accepts ReadonlyContext and returns the instruction
171169
def instruction_provider(context: ReadonlyContext) -> str:
172-
return AgentBuilderAssistant._compile_instruction_with_context(
173-
instruction_text, context, working_directory
170+
# Extract project folder name from session state
171+
project_folder_name = AgentBuilderAssistant._extract_project_folder_name(
172+
context
173+
)
174+
175+
# Fill the instruction template with all variables
176+
instruction_text = instruction_template.format(
177+
schema_content=schema_content,
178+
default_model=model_str,
179+
project_folder_name=project_folder_name,
174180
)
181+
return instruction_text
175182

176183
return instruction_provider
177184

185+
@staticmethod
186+
def _extract_project_folder_name(context: ReadonlyContext) -> str:
187+
"""Extract project folder name from session state using resolve_file_path."""
188+
from .utils.resolve_root_directory import resolve_file_path
189+
190+
session_state = context._invocation_context.session.state
191+
192+
# Use resolve_file_path to get the full resolved path for "."
193+
# This handles all the root_directory resolution logic consistently
194+
resolved_path = resolve_file_path(".", session_state)
195+
196+
# Extract the project folder name from the resolved path
197+
project_folder_name = resolved_path.name
198+
199+
# Fallback to "project" if we somehow get an empty name
200+
if not project_folder_name:
201+
project_folder_name = "project"
202+
203+
return project_folder_name
204+
178205
@staticmethod
179206
def _load_embedded_schema_instruction_template() -> str:
180207
"""Load instruction template for embedded ADK AgentConfig schema mode."""
@@ -187,70 +214,3 @@ def _load_embedded_schema_instruction_template() -> str:
187214

188215
with open(template_path, "r", encoding="utf-8") as f:
189216
return f.read()
190-
191-
@staticmethod
192-
def _compile_instruction_with_context(
193-
instruction_text: str,
194-
context: ReadonlyContext,
195-
working_directory: Optional[str] = None,
196-
) -> str:
197-
"""Compile instruction with session context and working directory information.
198-
199-
This method enhances instructions with:
200-
1. Working directory information for path resolution
201-
2. Session-based root directory binding if available
202-
203-
Args:
204-
instruction_text: Base instruction text
205-
context: ReadonlyContext from the agent session
206-
working_directory: Optional working directory for path resolution
207-
208-
Returns:
209-
Enhanced instruction text with context information
210-
"""
211-
import os
212-
213-
# Get working directory (use provided or current working directory)
214-
actual_working_dir = working_directory or os.getcwd()
215-
216-
# Check for existing root directory in session state
217-
session_root_directory = context._invocation_context.session.state.get(
218-
"root_directory"
219-
)
220-
221-
# Compile additional context information
222-
context_info = f"""
223-
224-
## SESSION CONTEXT
225-
226-
**Working Directory**: `{actual_working_dir}`
227-
- Use this as the base directory for path resolution when calling resolve_root_directory
228-
- Pass this as the working_directory parameter to resolve_root_directory tool
229-
230-
"""
231-
232-
if session_root_directory:
233-
context_info += f"""**Established Root Directory**: `{session_root_directory}`
234-
- This session is bound to root directory: {session_root_directory}
235-
- DO NOT ask the user for root directory - use this established path
236-
- All agent building should happen within this root directory
237-
- If user wants to work in a different directory, ask them to start a new chat session
238-
239-
"""
240-
else:
241-
context_info += f"""**Root Directory**: Not yet established
242-
- You MUST ask the user for their desired root directory first
243-
- Use resolve_root_directory tool to validate the path
244-
- Once confirmed, this session will be bound to that root directory
245-
246-
"""
247-
248-
context_info += """**Session Binding Rules**:
249-
- Each chat session is bound to ONE root directory
250-
- Once established, work only within that root directory
251-
- To switch directories, user must start a new chat session
252-
- Always verify paths using resolve_root_directory tool before creating files
253-
254-
"""
255-
256-
return instruction_text + context_info

0 commit comments

Comments
 (0)