google-adk 1.6.1__py3-none-any.whl → 1.8.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. google/adk/a2a/converters/event_converter.py +5 -85
  2. google/adk/a2a/converters/request_converter.py +1 -2
  3. google/adk/a2a/executor/a2a_agent_executor.py +45 -16
  4. google/adk/a2a/logs/log_utils.py +1 -2
  5. google/adk/a2a/utils/__init__.py +0 -0
  6. google/adk/a2a/utils/agent_card_builder.py +544 -0
  7. google/adk/a2a/utils/agent_to_a2a.py +118 -0
  8. google/adk/agents/__init__.py +5 -0
  9. google/adk/agents/agent_config.py +46 -0
  10. google/adk/agents/base_agent.py +239 -41
  11. google/adk/agents/callback_context.py +41 -0
  12. google/adk/agents/common_configs.py +79 -0
  13. google/adk/agents/config_agent_utils.py +184 -0
  14. google/adk/agents/config_schemas/AgentConfig.json +566 -0
  15. google/adk/agents/invocation_context.py +5 -1
  16. google/adk/agents/live_request_queue.py +15 -0
  17. google/adk/agents/llm_agent.py +201 -9
  18. google/adk/agents/loop_agent.py +35 -1
  19. google/adk/agents/parallel_agent.py +24 -3
  20. google/adk/agents/remote_a2a_agent.py +17 -5
  21. google/adk/agents/sequential_agent.py +22 -1
  22. google/adk/artifacts/gcs_artifact_service.py +110 -20
  23. google/adk/auth/auth_handler.py +3 -3
  24. google/adk/auth/credential_manager.py +23 -23
  25. google/adk/auth/credential_service/base_credential_service.py +6 -6
  26. google/adk/auth/credential_service/in_memory_credential_service.py +10 -8
  27. google/adk/auth/credential_service/session_state_credential_service.py +8 -8
  28. google/adk/auth/exchanger/oauth2_credential_exchanger.py +3 -3
  29. google/adk/auth/oauth2_credential_util.py +2 -2
  30. google/adk/auth/refresher/oauth2_credential_refresher.py +4 -4
  31. google/adk/cli/agent_graph.py +3 -1
  32. google/adk/cli/browser/index.html +2 -2
  33. google/adk/cli/browser/main-W7QZBYAR.js +3914 -0
  34. google/adk/cli/browser/polyfills-B6TNHZQ6.js +17 -0
  35. google/adk/cli/cli_eval.py +87 -12
  36. google/adk/cli/cli_tools_click.py +143 -82
  37. google/adk/cli/fast_api.py +150 -69
  38. google/adk/cli/utils/agent_loader.py +35 -1
  39. google/adk/code_executors/base_code_executor.py +14 -19
  40. google/adk/code_executors/built_in_code_executor.py +4 -1
  41. google/adk/evaluation/base_eval_service.py +46 -2
  42. google/adk/evaluation/eval_metrics.py +4 -0
  43. google/adk/evaluation/eval_sets_manager.py +5 -1
  44. google/adk/evaluation/evaluation_generator.py +1 -1
  45. google/adk/evaluation/final_response_match_v2.py +2 -2
  46. google/adk/evaluation/gcs_eval_sets_manager.py +2 -1
  47. google/adk/evaluation/in_memory_eval_sets_manager.py +151 -0
  48. google/adk/evaluation/local_eval_service.py +389 -0
  49. google/adk/evaluation/local_eval_set_results_manager.py +2 -2
  50. google/adk/evaluation/local_eval_sets_manager.py +24 -9
  51. google/adk/evaluation/metric_evaluator_registry.py +16 -6
  52. google/adk/evaluation/vertex_ai_eval_facade.py +7 -1
  53. google/adk/events/event.py +7 -2
  54. google/adk/flows/llm_flows/auto_flow.py +6 -11
  55. google/adk/flows/llm_flows/base_llm_flow.py +66 -29
  56. google/adk/flows/llm_flows/contents.py +16 -10
  57. google/adk/flows/llm_flows/functions.py +89 -52
  58. google/adk/memory/in_memory_memory_service.py +21 -15
  59. google/adk/memory/vertex_ai_memory_bank_service.py +12 -10
  60. google/adk/models/anthropic_llm.py +46 -6
  61. google/adk/models/base_llm_connection.py +2 -0
  62. google/adk/models/gemini_llm_connection.py +17 -6
  63. google/adk/models/google_llm.py +46 -11
  64. google/adk/models/lite_llm.py +52 -22
  65. google/adk/plugins/__init__.py +17 -0
  66. google/adk/plugins/base_plugin.py +317 -0
  67. google/adk/plugins/plugin_manager.py +265 -0
  68. google/adk/runners.py +122 -18
  69. google/adk/sessions/database_session_service.py +51 -52
  70. google/adk/sessions/vertex_ai_session_service.py +27 -12
  71. google/adk/tools/__init__.py +2 -0
  72. google/adk/tools/_automatic_function_calling_util.py +20 -2
  73. google/adk/tools/agent_tool.py +15 -3
  74. google/adk/tools/apihub_tool/apihub_toolset.py +38 -39
  75. google/adk/tools/application_integration_tool/application_integration_toolset.py +35 -37
  76. google/adk/tools/application_integration_tool/integration_connector_tool.py +2 -3
  77. google/adk/tools/base_tool.py +9 -9
  78. google/adk/tools/base_toolset.py +29 -5
  79. google/adk/tools/bigquery/__init__.py +3 -3
  80. google/adk/tools/bigquery/metadata_tool.py +2 -0
  81. google/adk/tools/bigquery/query_tool.py +15 -1
  82. google/adk/tools/computer_use/__init__.py +13 -0
  83. google/adk/tools/computer_use/base_computer.py +265 -0
  84. google/adk/tools/computer_use/computer_use_tool.py +166 -0
  85. google/adk/tools/computer_use/computer_use_toolset.py +220 -0
  86. google/adk/tools/enterprise_search_tool.py +4 -2
  87. google/adk/tools/exit_loop_tool.py +1 -0
  88. google/adk/tools/google_api_tool/google_api_tool.py +16 -1
  89. google/adk/tools/google_api_tool/google_api_toolset.py +9 -7
  90. google/adk/tools/google_api_tool/google_api_toolsets.py +41 -20
  91. google/adk/tools/google_search_tool.py +4 -2
  92. google/adk/tools/langchain_tool.py +16 -6
  93. google/adk/tools/long_running_tool.py +21 -0
  94. google/adk/tools/mcp_tool/mcp_toolset.py +27 -28
  95. google/adk/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.py +5 -0
  96. google/adk/tools/openapi_tool/openapi_spec_parser/openapi_toolset.py +8 -8
  97. google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py +4 -6
  98. google/adk/tools/retrieval/vertex_ai_rag_retrieval.py +3 -2
  99. google/adk/tools/tool_context.py +0 -10
  100. google/adk/tools/url_context_tool.py +4 -2
  101. google/adk/tools/vertex_ai_search_tool.py +4 -2
  102. google/adk/utils/model_name_utils.py +90 -0
  103. google/adk/version.py +1 -1
  104. {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/METADATA +3 -2
  105. {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/RECORD +108 -91
  106. google/adk/cli/browser/main-RXDVX3K6.js +0 -3914
  107. google/adk/cli/browser/polyfills-FFHMD2TL.js +0 -17
  108. {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/WHEEL +0 -0
  109. {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/entry_points.txt +0 -0
  110. {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,184 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
17
+ import importlib
18
+ import os
19
+ from typing import Any
20
+ from typing import List
21
+
22
+ import yaml
23
+
24
+ from ..utils.feature_decorator import working_in_progress
25
+ from .agent_config import AgentConfig
26
+ from .base_agent import BaseAgent
27
+ from .base_agent import SubAgentConfig
28
+ from .common_configs import CodeConfig
29
+ from .llm_agent import LlmAgent
30
+ from .llm_agent import LlmAgentConfig
31
+ from .loop_agent import LoopAgent
32
+ from .loop_agent import LoopAgentConfig
33
+ from .parallel_agent import ParallelAgent
34
+ from .parallel_agent import ParallelAgentConfig
35
+ from .sequential_agent import SequentialAgent
36
+ from .sequential_agent import SequentialAgentConfig
37
+
38
+
39
+ @working_in_progress("from_config is not ready for use.")
40
+ def from_config(config_path: str) -> BaseAgent:
41
+ """Build agent from a configfile path.
42
+
43
+ Args:
44
+ config: the path to a YAML config file.
45
+
46
+ Returns:
47
+ The created agent instance.
48
+
49
+ Raises:
50
+ FileNotFoundError: If config file doesn't exist.
51
+ ValidationError: If config file's content is invalid YAML.
52
+ ValueError: If agent type is unsupported.
53
+ """
54
+ abs_path = os.path.abspath(config_path)
55
+ config = _load_config_from_path(abs_path)
56
+
57
+ if isinstance(config.root, LlmAgentConfig):
58
+ return LlmAgent.from_config(config.root, abs_path)
59
+ elif isinstance(config.root, LoopAgentConfig):
60
+ return LoopAgent.from_config(config.root, abs_path)
61
+ elif isinstance(config.root, ParallelAgentConfig):
62
+ return ParallelAgent.from_config(config.root, abs_path)
63
+ elif isinstance(config.root, SequentialAgentConfig):
64
+ return SequentialAgent.from_config(config.root, abs_path)
65
+ else:
66
+ raise ValueError("Unsupported config type")
67
+
68
+
69
+ @working_in_progress("_load_config_from_path is not ready for use.")
70
+ def _load_config_from_path(config_path: str) -> AgentConfig:
71
+ """Load an agent's configuration from a YAML file.
72
+
73
+ Args:
74
+ config_path: Path to the YAML config file. Both relative and absolute
75
+ paths are accepted.
76
+
77
+ Returns:
78
+ The loaded and validated AgentConfig object.
79
+
80
+ Raises:
81
+ FileNotFoundError: If config file doesn't exist.
82
+ ValidationError: If config file's content is invalid YAML.
83
+ """
84
+ if not os.path.exists(config_path):
85
+ raise FileNotFoundError(f"Config file not found: {config_path}")
86
+
87
+ with open(config_path, "r", encoding="utf-8") as f:
88
+ config_data = yaml.safe_load(f)
89
+
90
+ return AgentConfig.model_validate(config_data)
91
+
92
+
93
+ @working_in_progress("build_sub_agent is not ready for use.")
94
+ def build_sub_agent(
95
+ sub_config: SubAgentConfig, parent_agent_folder_path: str
96
+ ) -> BaseAgent:
97
+ """Build a sub-agent from configuration.
98
+
99
+ Args:
100
+ sub_config: The sub-agent configuration (SubAgentConfig).
101
+ parent_agent_folder_path: The folder path to the parent agent's YAML config.
102
+
103
+ Returns:
104
+ The created sub-agent instance.
105
+ """
106
+ if sub_config.config:
107
+ if os.path.isabs(sub_config.config):
108
+ return from_config(sub_config.config)
109
+ else:
110
+ return from_config(
111
+ os.path.join(parent_agent_folder_path, sub_config.config)
112
+ )
113
+ elif sub_config.code:
114
+ return _resolve_sub_agent_code_reference(sub_config.code)
115
+ else:
116
+ raise ValueError("SubAgentConfig must have either 'code' or 'config'")
117
+
118
+
119
+ @working_in_progress("_resolve_sub_agent_code_reference is not ready for use.")
120
+ def _resolve_sub_agent_code_reference(code: str) -> Any:
121
+ """Resolve a code reference to an actual agent object.
122
+
123
+ Args:
124
+ code: The code reference to the sub-agent.
125
+
126
+ Returns:
127
+ The resolved agent object.
128
+
129
+ Raises:
130
+ ValueError: If the code reference cannot be resolved.
131
+ """
132
+ if "." not in code:
133
+ raise ValueError(f"Invalid code reference: {code}")
134
+
135
+ module_path, obj_name = code.rsplit(".", 1)
136
+ module = importlib.import_module(module_path)
137
+ obj = getattr(module, obj_name)
138
+
139
+ if callable(obj):
140
+ raise ValueError(f"Invalid code reference to a callable: {code}")
141
+
142
+ return obj
143
+
144
+
145
+ @working_in_progress("resolve_code_reference is not ready for use.")
146
+ def resolve_code_reference(code_config: CodeConfig) -> Any:
147
+ """Resolve a code reference to actual Python object.
148
+
149
+ Args:
150
+ code_config: The code configuration (CodeConfig).
151
+
152
+ Returns:
153
+ The resolved Python object.
154
+
155
+ Raises:
156
+ ValueError: If the code reference cannot be resolved.
157
+ """
158
+ if not code_config or not code_config.name:
159
+ raise ValueError("Invalid CodeConfig.")
160
+
161
+ module_path, obj_name = code_config.name.rsplit(".", 1)
162
+ module = importlib.import_module(module_path)
163
+ obj = getattr(module, obj_name)
164
+
165
+ if code_config.args and callable(obj):
166
+ kwargs = {arg.name: arg.value for arg in code_config.args if arg.name}
167
+ positional_args = [arg.value for arg in code_config.args if not arg.name]
168
+
169
+ return obj(*positional_args, **kwargs)
170
+ else:
171
+ return obj
172
+
173
+
174
+ @working_in_progress("resolve_callbacks is not ready for use.")
175
+ def resolve_callbacks(callbacks_config: List[CodeConfig]) -> Any:
176
+ """Resolve callbacks from configuration.
177
+
178
+ Args:
179
+ callbacks_config: List of callback configurations (CodeConfig objects).
180
+
181
+ Returns:
182
+ List of resolved callback objects.
183
+ """
184
+ return [resolve_code_reference(config) for config in callbacks_config]