Skip to content

Commit e0e7625

Browse files
GWealecopybara-github
authored andcommitted
docs: Use a trimmed ADK AgentConfig schema in Agent Builder Assistant
This trimmed schema includes only the fields relevant to agent shells, tool wiring, and common generation parameters, improving efficiency and focus. The default model for the assistant has also been updated to "gemini-2.5-pro" Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 829513627
1 parent 8f3c3bf commit e0e7625

File tree

1 file changed

+55
-6
lines changed

1 file changed

+55
-6
lines changed

contributing/samples/adk_agent_builder_assistant/agent_builder_assistant.py

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,28 @@
4545
class AgentBuilderAssistant:
4646
"""Agent Builder Assistant factory for creating configured instances."""
4747

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+
4867
@staticmethod
4968
def create_agent(
50-
model: Union[str, BaseLlm] = "gemini-2.5-flash",
69+
model: Union[str, BaseLlm] = "gemini-2.5-pro",
5170
working_directory: Optional[str] = None,
5271
) -> LlmAgent:
5372
"""Create Agent Builder Assistant with embedded ADK AgentConfig schema.
@@ -127,11 +146,9 @@ def create_agent(
127146
def _load_schema() -> str:
128147
"""Load ADK AgentConfig.json schema content and format for YAML embedding."""
129148

130-
# CENTRALIZED ADK AGENTCONFIG SCHEMA LOADING: Use common utility function
131-
# This avoids duplication across multiple files and provides consistent
132-
# ADK AgentConfig schema loading with caching and error handling.
133-
schema_dict = load_agent_config_schema()
134-
return AgentBuilderAssistant._build_schema_reference(schema_dict)
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)
135152

136153
@staticmethod
137154
def _build_schema_reference(schema: dict[str, Any]) -> str:
@@ -300,6 +317,38 @@ def add(text: str = "", indent: int = 0) -> None:
300317

301318
return "```text\n" + "\n".join(lines) + "\n```"
302319

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+
}
351+
303352
@staticmethod
304353
def _load_instruction_with_schema(
305354
model: Union[str, BaseLlm],

0 commit comments

Comments
 (0)