Skip to content

Commit 36eab15

Browse files
authored
Merge branch 'main' into ammmr-info-to-debug-connect-log
2 parents c090632 + 34ea2ed commit 36eab15

File tree

157 files changed

+11116
-1851
lines changed

Some content is hidden

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

157 files changed

+11116
-1851
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Steps to reproduce the behavior:
1919
1. Install '...'
2020
2. Run '....'
2121
3. Open '....'
22-
4. Provie error or stacktrace
22+
4. Provide error or stacktrace
2323

2424
**Expected behavior**
2525
A clear and concise description of what you expected to happen.

CHANGELOG.md

Lines changed: 110 additions & 10 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ deployment-agnostic, and compatible with other frameworks.
3232

3333
## 🔥 What's new
3434

35-
- **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))
35+
- **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](https://github.com/google/adk-python/discussions/3175#discussioncomment-14745120). ([391628f](https://github.com/google/adk-python/commit/391628fcdc7b950c6835f64ae3ccab197163c990))
3636

3737
- **Rewind**: Add the ability to rewind a session to before a previous invocation ([9dce06f](https://github.com/google/adk-python/commit/9dce06f9b00259ec42241df4f6638955e783a9d1)).
3838

contributing/samples/adk_agent_builder_assistant/agent_builder_assistant.py

Lines changed: 222 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"""Agent factory for creating Agent Builder Assistant with embedded schema."""
1616

1717
from pathlib import Path
18+
import textwrap
19+
from typing import Any
1820
from typing import Callable
1921
from typing import Optional
2022
from typing import Union
@@ -43,9 +45,28 @@
4345
class AgentBuilderAssistant:
4446
"""Agent Builder Assistant factory for creating configured instances."""
4547

48+
_CORE_SCHEMA_DEF_NAMES: tuple[str, ...] = (
49+
"LlmAgentConfig",
50+
"LoopAgentConfig",
51+
"ParallelAgentConfig",
52+
"SequentialAgentConfig",
53+
"BaseAgentConfig",
54+
"AgentRefConfig",
55+
"CodeConfig",
56+
"ArgumentConfig",
57+
"ToolArgsConfig",
58+
"google__adk__tools__tool_configs__ToolConfig",
59+
)
60+
_GEN_CONFIG_FIELDS: tuple[str, ...] = (
61+
"temperature",
62+
"topP",
63+
"topK",
64+
"maxOutputTokens",
65+
)
66+
4667
@staticmethod
4768
def create_agent(
48-
model: Union[str, BaseLlm] = "gemini-2.5-flash",
69+
model: Union[str, BaseLlm] = "gemini-2.5-pro",
4970
working_directory: Optional[str] = None,
5071
) -> LlmAgent:
5172
"""Create Agent Builder Assistant with embedded ADK AgentConfig schema.
@@ -125,28 +146,208 @@ def create_agent(
125146
def _load_schema() -> str:
126147
"""Load ADK AgentConfig.json schema content and format for YAML embedding."""
127148

128-
# CENTRALIZED ADK AGENTCONFIG SCHEMA LOADING: Use common utility function
129-
# This avoids duplication across multiple files and provides consistent
130-
# ADK AgentConfig schema loading with caching and error handling.
131-
schema_content = load_agent_config_schema(
132-
raw_format=True, # Get as JSON string
149+
schema_dict = load_agent_config_schema(raw_format=False)
150+
subset = AgentBuilderAssistant._extract_core_schema(schema_dict)
151+
return AgentBuilderAssistant._build_schema_reference(subset)
152+
153+
@staticmethod
154+
def _build_schema_reference(schema: dict[str, Any]) -> str:
155+
"""Create compact AgentConfig reference text for prompt embedding."""
156+
157+
defs: dict[str, Any] = schema.get("$defs", {})
158+
top_level_fields: dict[str, Any] = schema.get("properties", {})
159+
wrapper = textwrap.TextWrapper(width=78)
160+
lines: list[str] = []
161+
162+
def add(text: str = "", indent: int = 0) -> None:
163+
"""Append wrapped text with indentation."""
164+
if not text:
165+
lines.append("")
166+
return
167+
indent_str = " " * indent
168+
wrapper.initial_indent = indent_str
169+
wrapper.subsequent_indent = indent_str
170+
lines.extend(wrapper.fill(text).split("\n"))
171+
172+
add("ADK AgentConfig quick reference")
173+
add("--------------------------------")
174+
175+
add()
176+
add("LlmAgent (agent_class: LlmAgent)")
177+
add(
178+
"Required fields: name, instruction. ADK best practice is to always set"
179+
" model explicitly.",
180+
indent=2,
181+
)
182+
add("Optional fields:", indent=2)
183+
add("agent_class: defaults to LlmAgent; keep for clarity.", indent=4)
184+
add("description: short summary string.", indent=4)
185+
add("sub_agents: list of AgentRef entries (see below).", indent=4)
186+
add(
187+
"before_agent_callbacks / after_agent_callbacks: list of CodeConfig "
188+
"entries that run before or after the agent loop.",
189+
indent=4,
190+
)
191+
add("model: string model id (required in practice).", indent=4)
192+
add(
193+
"disallow_transfer_to_parent / disallow_transfer_to_peers: booleans to "
194+
"restrict automatic transfer.",
195+
indent=4,
196+
)
197+
add(
198+
"input_schema / output_schema: JSON schema objects to validate inputs "
199+
"and outputs.",
200+
indent=4,
201+
)
202+
add("output_key: name to store agent output in session context.", indent=4)
203+
add(
204+
"include_contents: bool; include tool/LLM contents in response.",
205+
indent=4,
206+
)
207+
add("tools: list of ToolConfig entries (see below).", indent=4)
208+
add(
209+
"before_model_callbacks / after_model_callbacks: list of CodeConfig "
210+
"entries around LLM calls.",
211+
indent=4,
212+
)
213+
add(
214+
"before_tool_callbacks / after_tool_callbacks: list of CodeConfig "
215+
"entries around tool calls.",
216+
indent=4,
217+
)
218+
add(
219+
"generate_content_config: passes directly to google.genai "
220+
"GenerateContentConfig (supporting temperature, topP, topK, "
221+
"maxOutputTokens, safetySettings, responseSchema, routingConfig,"
222+
" etc.).",
223+
indent=4,
133224
)
134225

135-
# Format as indented code block for instruction embedding
136-
#
137-
# Why indentation is needed:
138-
# - The ADK AgentConfig schema gets embedded into instruction templates using .format()
139-
# - Proper indentation maintains readability in the final instruction
140-
# - Code block markers (```) help LLMs recognize this as structured data
141-
#
142-
# Example final instruction format:
143-
# "Here is the ADK AgentConfig schema:
144-
# ```json
145-
# {"type": "object", "properties": {...}}
146-
# ```"
147-
lines = schema_content.split("\n")
148-
indented_lines = [" " + line for line in lines] # 2-space indent
149-
return "```json\n" + "\n".join(indented_lines) + "\n ```"
226+
add()
227+
add("Workflow agents (LoopAgent, ParallelAgent, SequentialAgent)")
228+
add(
229+
"Share BaseAgent fields: agent_class, name, description, sub_agents, "
230+
"before/after_agent_callbacks. Never declare model, instruction, or "
231+
"tools on workflow orchestrators.",
232+
indent=2,
233+
)
234+
add(
235+
"LoopAgent adds max_iterations (int) controlling iteration cap.",
236+
indent=2,
237+
)
238+
239+
add()
240+
add("AgentRef")
241+
add(
242+
"Used inside sub_agents lists. Provide either config_path (string path "
243+
"to another YAML file) or code (dotted Python reference) to locate the "
244+
"sub-agent definition.",
245+
indent=2,
246+
)
247+
248+
add()
249+
add("ToolConfig")
250+
add(
251+
"Items inside tools arrays. Required field name (string). For built-in "
252+
"tools use the exported short name, for custom tools use the dotted "
253+
"module path.",
254+
indent=2,
255+
)
256+
add(
257+
"args: optional object of additional keyword arguments. Use simple "
258+
"key-value pairs (ToolArgsConfig) or structured ArgumentConfig entries "
259+
"when a list is required by callbacks.",
260+
indent=2,
261+
)
262+
263+
add()
264+
add("ArgumentConfig")
265+
add(
266+
"Represents a single argument. value is required and may be any JSON "
267+
"type. name is optional (null allowed). Often used in callback args.",
268+
indent=2,
269+
)
270+
271+
add()
272+
add("CodeConfig")
273+
add(
274+
"References Python code for callbacks or dynamic tool creation."
275+
" Requires name (dotted path). args is an optional list of"
276+
" ArgumentConfig items executed when invoking the function.",
277+
indent=2,
278+
)
279+
280+
add()
281+
add("GenerateContentConfig highlights")
282+
add(
283+
"Controls LLM generation behavior. Common fields: maxOutputTokens, "
284+
"temperature, topP, topK, candidateCount, responseMimeType, "
285+
"responseSchema/responseJsonSchema, automaticFunctionCalling, "
286+
"safetySettings, routingConfig; see Vertex AI GenAI docs for full "
287+
"semantics.",
288+
indent=2,
289+
)
290+
291+
add()
292+
add(
293+
"All other schema definitions in AgentConfig.json remain available but "
294+
"are rarely needed for typical agent setups. Refer to the source file "
295+
"for exhaustive field descriptions when implementing advanced configs.",
296+
)
297+
298+
if top_level_fields:
299+
add()
300+
add("Top-level AgentConfig fields (from schema)")
301+
for field_name in sorted(top_level_fields):
302+
description = top_level_fields[field_name].get("description", "")
303+
if description:
304+
add(f"{field_name}: {description}", indent=2)
305+
else:
306+
add(field_name, indent=2)
307+
308+
if defs:
309+
add()
310+
add("Additional schema definitions")
311+
for def_name in sorted(defs):
312+
description = defs[def_name].get("description", "")
313+
if description:
314+
add(f"{def_name}: {description}", indent=2)
315+
else:
316+
add(def_name, indent=2)
317+
318+
return "```text\n" + "\n".join(lines) + "\n```"
319+
320+
@staticmethod
321+
def _extract_core_schema(schema: dict[str, Any]) -> dict[str, Any]:
322+
"""Return only the schema nodes surfaced by the assistant."""
323+
324+
defs = schema.get("$defs", {})
325+
filtered_defs: dict[str, Any] = {}
326+
for key in AgentBuilderAssistant._CORE_SCHEMA_DEF_NAMES:
327+
if key in defs:
328+
filtered_defs[key] = defs[key]
329+
330+
gen_config = defs.get("GenerateContentConfig")
331+
if gen_config:
332+
properties = gen_config.get("properties", {})
333+
filtered_defs["GenerateContentConfig"] = {
334+
"title": gen_config.get("title", "GenerateContentConfig"),
335+
"description": (
336+
"Common LLM generation knobs exposed by the Agent Builder."
337+
),
338+
"type": "object",
339+
"additionalProperties": False,
340+
"properties": {
341+
key: properties[key]
342+
for key in AgentBuilderAssistant._GEN_CONFIG_FIELDS
343+
if key in properties
344+
},
345+
}
346+
347+
return {
348+
"$defs": filtered_defs,
349+
"properties": schema.get("properties", {}),
350+
}
150351

151352
@staticmethod
152353
def _load_instruction_with_schema(

contributing/samples/adk_agent_builder_assistant/tools/search_adk_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def search_adk_source(
4646
max_results: Maximum number of results to return (default: 20)
4747
context_lines: Number of context lines to include around matches (default:
4848
3)
49-
case_sensitive: Whether search should be case sensitive (default: False)
49+
case_sensitive: Whether search should be case-sensitive (default: False)
5050
5151
Returns:
5252
Dict containing search results:

contributing/samples/adk_agent_builder_assistant/tools/write_config_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def write_config_files(
6666
6767
Args:
6868
configs: Dict mapping file_path to config_content (YAML as string)
69-
backup_existing: Whether to create timest amped backup of existing files
69+
backup_existing: Whether to create timestamped backup of existing files
7070
before overwriting (default: False, User should decide)
7171
create_directories: Whether to create parent directories if they don't exist
7272
(default: True)

contributing/samples/adk_answering_agent/agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
6262
3. **Decide whether to respond**:
6363
* If all the following conditions are met, try to add a comment to the
64-
discussion, otherwise, do not respond:
64+
discussion; otherwise, do not respond:
6565
- The discussion is not closed.
6666
- The latest comment is not from you or other agents (marked as
6767
"Response from XXX Agent").
@@ -102,7 +102,7 @@
102102
* You **should always** use the `convert_gcs_links_to_https` tool to convert
103103
GCS links (e.g. "gs://...") to HTTPS links.
104104
* **Do not** use the `convert_gcs_links_to_https` tool for non-GCS links.
105-
* Make sure the citation URL is valid. Otherwise do not list this specific
105+
* Make sure the citation URL is valid. Otherwise, do not list this specific
106106
citation.
107107
* Do not respond to any other discussion except the one specified by the user.
108108

contributing/samples/adk_answering_agent/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def convert_gcs_to_https(gcs_uri: str) -> Optional[str]:
128128

129129
base_url = "https://google.github.io/adk-docs/"
130130
if os.path.basename(path_after_docs) == "index.md":
131-
# Use the directory path if it is a index file
131+
# Use the directory path if it is an index file
132132
final_path_segment = os.path.dirname(path_after_docs)
133133
else:
134134
# Otherwise, use the file name without extension

contributing/samples/adk_documentation/adk_docs_updater/agent.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
),
5555
instruction=f"""
5656
# 1. Identity
57-
You are a helper bot that updates ADK docs in Github Repository {DOC_OWNER}/{DOC_REPO}
58-
based on the code in the ADK Python codebase in Github Repository {CODE_OWNER}/{CODE_REPO} according to the instructions in the ADK docs issues.
57+
You are a helper bot that updates ADK docs in GitHub Repository {DOC_OWNER}/{DOC_REPO}
58+
based on the code in the ADK Python codebase in GitHub Repository {CODE_OWNER}/{CODE_REPO} according to the instructions in the ADK docs issues.
5959
60-
You are very familiar with Github, expecially how to search for files in a Github repository using git grep.
60+
You are very familiar with GitHub, especially how to search for files in a GitHub repository using git grep.
6161
6262
# 2. Responsibilities
6363
Your core responsibility includes:
@@ -69,18 +69,18 @@
6969
# 3. Workflow
7070
1. Always call the `clone_or_pull_repo` tool to make sure the ADK docs and codebase repos exist in the local folder {LOCAL_REPOS_DIR_PATH}/repo_name and are the latest version.
7171
2. Read and analyze the issue specified by user.
72-
- If user only specified the issue number, call the `get_issue` tool to get the issue details, otherwise use the issue details provided by user directly.
72+
- If user only specified the issue number, call the `get_issue` tool to get the issue details; otherwise, use the issue details provided by user directly.
7373
3. If the issue contains instructions about how to update the ADK docs, follow the instructions to update the ADK docs.
7474
4. Understand the doc update instructions.
7575
- Ignore and skip the instructions about updating API reference docs, since it will be automatically generated by the ADK team.
7676
5. Read the doc to update using the `read_local_git_repo_file_content` tool from the local ADK docs repo under {LOCAL_REPOS_DIR_PATH}/{DOC_REPO}.
7777
6. Find the related Python files in the ADK Python codebase.
78-
- If the doc update instructions specify paths to the Python files, use them directly, otherwise use a list of regex search patterns to find the related Python files through the `search_local_git_repo` tool.
78+
- If the doc update instructions specify paths to the Python files, use them directly; otherwise, use a list of regex search patterns to find the related Python files through the `search_local_git_repo` tool.
7979
- You should focus on the main ADK Python codebase, ignore the changes in tests or other auxiliary files.
8080
- You should find all the related Python files, not only the most relevant one.
8181
7. Read the specified or found Python files using the `read_local_git_repo_file_content` tool to find all the related code.
82-
- You can ignore unit test files, unless you are sure that the test code is uesful to understand the related concepts.
83-
- You should read all the the found files to find all the related code, unless you already know the content of the file or you are sure that the file is not related to the ADK doc.
82+
- You can ignore unit test files, unless you are sure that the test code is useful to understand the related concepts.
83+
- You should read all the found files to find all the related code, unless you already know the content of the file or you are sure that the file is not related to the ADK doc.
8484
8. Update the ADK doc file according to the doc update instructions and the related code.
8585
- Use active voice phrasing in your doc updates.
8686
- Use second person "you" form of address in your doc updates.
@@ -102,12 +102,12 @@
102102
- **File Paths:** Always use absolute paths when calling the tools to read files, list directories, or search the codebase.
103103
- **Tool Call Parallelism:** Execute multiple independent tool calls in parallel when feasible (i.e. searching the codebase).
104104
- **Avoid deletion:** Do not delete any existing content unless specifically directed to do so.
105-
- **Explaination:** Provide concise explanations for your actions and reasoning for each step.
105+
- **Explanation:** Provide concise explanations for your actions and reasoning for each step.
106106
- **Minimize changes:** When making updates to documentation pages, make the minimum amount of changes to achieve the communication goal. Only make changes that are necessary, and leave everything else as-is.
107107
- **Avoid trivial code sample changes:** Update code samples only when adding or modifying functionality. Do not reformat code samples, change variable names, or change code syntax unless you are specifically directed to make those updates.
108108
109109
# 5. Output
110-
Present the followings in an easy to read format as the final output to the user.
110+
Present the following in an easy to read format as the final output to the user.
111111
- The actions you took and the reasoning
112112
- The summary of the pull request created
113113
""",

0 commit comments

Comments
 (0)