|
45 | 45 | class AgentBuilderAssistant: |
46 | 46 | """Agent Builder Assistant factory for creating configured instances.""" |
47 | 47 |
|
| 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 | + |
48 | 67 | @staticmethod |
49 | 68 | def create_agent( |
50 | | - model: Union[str, BaseLlm] = "gemini-2.5-flash", |
| 69 | + model: Union[str, BaseLlm] = "gemini-2.5-pro", |
51 | 70 | working_directory: Optional[str] = None, |
52 | 71 | ) -> LlmAgent: |
53 | 72 | """Create Agent Builder Assistant with embedded ADK AgentConfig schema. |
@@ -127,11 +146,9 @@ def create_agent( |
127 | 146 | def _load_schema() -> str: |
128 | 147 | """Load ADK AgentConfig.json schema content and format for YAML embedding.""" |
129 | 148 |
|
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) |
135 | 152 |
|
136 | 153 | @staticmethod |
137 | 154 | def _build_schema_reference(schema: dict[str, Any]) -> str: |
@@ -300,6 +317,38 @@ def add(text: str = "", indent: int = 0) -> None: |
300 | 317 |
|
301 | 318 | return "```text\n" + "\n".join(lines) + "\n```" |
302 | 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 | + } |
| 351 | + |
303 | 352 | @staticmethod |
304 | 353 | def _load_instruction_with_schema( |
305 | 354 | model: Union[str, BaseLlm], |
|
0 commit comments