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.
- google/adk/a2a/converters/event_converter.py +5 -85
- google/adk/a2a/converters/request_converter.py +1 -2
- google/adk/a2a/executor/a2a_agent_executor.py +45 -16
- google/adk/a2a/logs/log_utils.py +1 -2
- google/adk/a2a/utils/__init__.py +0 -0
- google/adk/a2a/utils/agent_card_builder.py +544 -0
- google/adk/a2a/utils/agent_to_a2a.py +118 -0
- google/adk/agents/__init__.py +5 -0
- google/adk/agents/agent_config.py +46 -0
- google/adk/agents/base_agent.py +239 -41
- google/adk/agents/callback_context.py +41 -0
- google/adk/agents/common_configs.py +79 -0
- google/adk/agents/config_agent_utils.py +184 -0
- google/adk/agents/config_schemas/AgentConfig.json +566 -0
- google/adk/agents/invocation_context.py +5 -1
- google/adk/agents/live_request_queue.py +15 -0
- google/adk/agents/llm_agent.py +201 -9
- google/adk/agents/loop_agent.py +35 -1
- google/adk/agents/parallel_agent.py +24 -3
- google/adk/agents/remote_a2a_agent.py +17 -5
- google/adk/agents/sequential_agent.py +22 -1
- google/adk/artifacts/gcs_artifact_service.py +110 -20
- google/adk/auth/auth_handler.py +3 -3
- google/adk/auth/credential_manager.py +23 -23
- google/adk/auth/credential_service/base_credential_service.py +6 -6
- google/adk/auth/credential_service/in_memory_credential_service.py +10 -8
- google/adk/auth/credential_service/session_state_credential_service.py +8 -8
- google/adk/auth/exchanger/oauth2_credential_exchanger.py +3 -3
- google/adk/auth/oauth2_credential_util.py +2 -2
- google/adk/auth/refresher/oauth2_credential_refresher.py +4 -4
- google/adk/cli/agent_graph.py +3 -1
- google/adk/cli/browser/index.html +2 -2
- google/adk/cli/browser/main-W7QZBYAR.js +3914 -0
- google/adk/cli/browser/polyfills-B6TNHZQ6.js +17 -0
- google/adk/cli/cli_eval.py +87 -12
- google/adk/cli/cli_tools_click.py +143 -82
- google/adk/cli/fast_api.py +150 -69
- google/adk/cli/utils/agent_loader.py +35 -1
- google/adk/code_executors/base_code_executor.py +14 -19
- google/adk/code_executors/built_in_code_executor.py +4 -1
- google/adk/evaluation/base_eval_service.py +46 -2
- google/adk/evaluation/eval_metrics.py +4 -0
- google/adk/evaluation/eval_sets_manager.py +5 -1
- google/adk/evaluation/evaluation_generator.py +1 -1
- google/adk/evaluation/final_response_match_v2.py +2 -2
- google/adk/evaluation/gcs_eval_sets_manager.py +2 -1
- google/adk/evaluation/in_memory_eval_sets_manager.py +151 -0
- google/adk/evaluation/local_eval_service.py +389 -0
- google/adk/evaluation/local_eval_set_results_manager.py +2 -2
- google/adk/evaluation/local_eval_sets_manager.py +24 -9
- google/adk/evaluation/metric_evaluator_registry.py +16 -6
- google/adk/evaluation/vertex_ai_eval_facade.py +7 -1
- google/adk/events/event.py +7 -2
- google/adk/flows/llm_flows/auto_flow.py +6 -11
- google/adk/flows/llm_flows/base_llm_flow.py +66 -29
- google/adk/flows/llm_flows/contents.py +16 -10
- google/adk/flows/llm_flows/functions.py +89 -52
- google/adk/memory/in_memory_memory_service.py +21 -15
- google/adk/memory/vertex_ai_memory_bank_service.py +12 -10
- google/adk/models/anthropic_llm.py +46 -6
- google/adk/models/base_llm_connection.py +2 -0
- google/adk/models/gemini_llm_connection.py +17 -6
- google/adk/models/google_llm.py +46 -11
- google/adk/models/lite_llm.py +52 -22
- google/adk/plugins/__init__.py +17 -0
- google/adk/plugins/base_plugin.py +317 -0
- google/adk/plugins/plugin_manager.py +265 -0
- google/adk/runners.py +122 -18
- google/adk/sessions/database_session_service.py +51 -52
- google/adk/sessions/vertex_ai_session_service.py +27 -12
- google/adk/tools/__init__.py +2 -0
- google/adk/tools/_automatic_function_calling_util.py +20 -2
- google/adk/tools/agent_tool.py +15 -3
- google/adk/tools/apihub_tool/apihub_toolset.py +38 -39
- google/adk/tools/application_integration_tool/application_integration_toolset.py +35 -37
- google/adk/tools/application_integration_tool/integration_connector_tool.py +2 -3
- google/adk/tools/base_tool.py +9 -9
- google/adk/tools/base_toolset.py +29 -5
- google/adk/tools/bigquery/__init__.py +3 -3
- google/adk/tools/bigquery/metadata_tool.py +2 -0
- google/adk/tools/bigquery/query_tool.py +15 -1
- google/adk/tools/computer_use/__init__.py +13 -0
- google/adk/tools/computer_use/base_computer.py +265 -0
- google/adk/tools/computer_use/computer_use_tool.py +166 -0
- google/adk/tools/computer_use/computer_use_toolset.py +220 -0
- google/adk/tools/enterprise_search_tool.py +4 -2
- google/adk/tools/exit_loop_tool.py +1 -0
- google/adk/tools/google_api_tool/google_api_tool.py +16 -1
- google/adk/tools/google_api_tool/google_api_toolset.py +9 -7
- google/adk/tools/google_api_tool/google_api_toolsets.py +41 -20
- google/adk/tools/google_search_tool.py +4 -2
- google/adk/tools/langchain_tool.py +16 -6
- google/adk/tools/long_running_tool.py +21 -0
- google/adk/tools/mcp_tool/mcp_toolset.py +27 -28
- google/adk/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.py +5 -0
- google/adk/tools/openapi_tool/openapi_spec_parser/openapi_toolset.py +8 -8
- google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py +4 -6
- google/adk/tools/retrieval/vertex_ai_rag_retrieval.py +3 -2
- google/adk/tools/tool_context.py +0 -10
- google/adk/tools/url_context_tool.py +4 -2
- google/adk/tools/vertex_ai_search_tool.py +4 -2
- google/adk/utils/model_name_utils.py +90 -0
- google/adk/version.py +1 -1
- {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/METADATA +3 -2
- {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/RECORD +108 -91
- google/adk/cli/browser/main-RXDVX3K6.js +0 -3914
- google/adk/cli/browser/polyfills-FFHMD2TL.js +0 -17
- {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/WHEEL +0 -0
- {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/entry_points.txt +0 -0
- {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/licenses/LICENSE +0 -0
@@ -24,13 +24,11 @@ from typing import Optional
|
|
24
24
|
import uuid
|
25
25
|
|
26
26
|
from a2a.server.events import Event as A2AEvent
|
27
|
-
from a2a.types import Artifact
|
28
27
|
from a2a.types import DataPart
|
29
28
|
from a2a.types import Message
|
30
29
|
from a2a.types import Part as A2APart
|
31
30
|
from a2a.types import Role
|
32
31
|
from a2a.types import Task
|
33
|
-
from a2a.types import TaskArtifactUpdateEvent
|
34
32
|
from a2a.types import TaskState
|
35
33
|
from a2a.types import TaskStatus
|
36
34
|
from a2a.types import TaskStatusUpdateEvent
|
@@ -145,81 +143,6 @@ def _create_artifact_id(
|
|
145
143
|
return ARTIFACT_ID_SEPARATOR.join(components)
|
146
144
|
|
147
145
|
|
148
|
-
def _convert_artifact_to_a2a_events(
|
149
|
-
event: Event,
|
150
|
-
invocation_context: InvocationContext,
|
151
|
-
filename: str,
|
152
|
-
version: int,
|
153
|
-
task_id: Optional[str] = None,
|
154
|
-
context_id: Optional[str] = None,
|
155
|
-
) -> TaskArtifactUpdateEvent:
|
156
|
-
"""Converts a new artifact version to an A2A TaskArtifactUpdateEvent.
|
157
|
-
|
158
|
-
Args:
|
159
|
-
event: The ADK event containing the artifact information.
|
160
|
-
invocation_context: The invocation context.
|
161
|
-
filename: The name of the artifact file.
|
162
|
-
version: The version number of the artifact.
|
163
|
-
task_id: Optional task ID to use for generated events. If not provided, new UUIDs will be generated.
|
164
|
-
|
165
|
-
Returns:
|
166
|
-
A TaskArtifactUpdateEvent representing the artifact update.
|
167
|
-
|
168
|
-
Raises:
|
169
|
-
ValueError: If required parameters are invalid.
|
170
|
-
RuntimeError: If artifact loading fails.
|
171
|
-
"""
|
172
|
-
if not filename:
|
173
|
-
raise ValueError("Filename cannot be empty")
|
174
|
-
if version < 0:
|
175
|
-
raise ValueError("Version must be non-negative")
|
176
|
-
|
177
|
-
try:
|
178
|
-
artifact_part = invocation_context.artifact_service.load_artifact(
|
179
|
-
app_name=invocation_context.app_name,
|
180
|
-
user_id=invocation_context.user_id,
|
181
|
-
session_id=invocation_context.session.id,
|
182
|
-
filename=filename,
|
183
|
-
version=version,
|
184
|
-
)
|
185
|
-
|
186
|
-
converted_part = convert_genai_part_to_a2a_part(part=artifact_part)
|
187
|
-
if not converted_part:
|
188
|
-
raise RuntimeError(f"Failed to convert artifact part for {filename}")
|
189
|
-
|
190
|
-
artifact_id = _create_artifact_id(
|
191
|
-
invocation_context.app_name,
|
192
|
-
invocation_context.user_id,
|
193
|
-
invocation_context.session.id,
|
194
|
-
filename,
|
195
|
-
version,
|
196
|
-
)
|
197
|
-
|
198
|
-
return TaskArtifactUpdateEvent(
|
199
|
-
taskId=task_id,
|
200
|
-
append=False,
|
201
|
-
contextId=context_id,
|
202
|
-
lastChunk=True,
|
203
|
-
artifact=Artifact(
|
204
|
-
artifactId=artifact_id,
|
205
|
-
name=filename,
|
206
|
-
metadata={
|
207
|
-
"filename": filename,
|
208
|
-
"version": version,
|
209
|
-
},
|
210
|
-
parts=[converted_part],
|
211
|
-
),
|
212
|
-
)
|
213
|
-
except Exception as e:
|
214
|
-
logger.error(
|
215
|
-
"Failed to convert artifact for %s, version %s: %s",
|
216
|
-
filename,
|
217
|
-
version,
|
218
|
-
e,
|
219
|
-
)
|
220
|
-
raise RuntimeError(f"Artifact conversion failed: {e}") from e
|
221
|
-
|
222
|
-
|
223
146
|
def _process_long_running_tool(a2a_part: A2APart, event: Event) -> None:
|
224
147
|
"""Processes long-running tool metadata for an A2A part.
|
225
148
|
|
@@ -268,7 +191,11 @@ def convert_a2a_task_to_event(
|
|
268
191
|
try:
|
269
192
|
# Extract message from task status or history
|
270
193
|
message = None
|
271
|
-
if a2a_task.
|
194
|
+
if a2a_task.artifacts:
|
195
|
+
message = Message(
|
196
|
+
messageId="", role=Role.agent, parts=a2a_task.artifacts[-1].parts
|
197
|
+
)
|
198
|
+
elif a2a_task.status and a2a_task.status.message:
|
272
199
|
message = a2a_task.status.message
|
273
200
|
elif a2a_task.history:
|
274
201
|
message = a2a_task.history[-1]
|
@@ -573,13 +500,6 @@ def convert_event_to_a2a_events(
|
|
573
500
|
a2a_events = []
|
574
501
|
|
575
502
|
try:
|
576
|
-
# Handle artifact deltas
|
577
|
-
if event.actions.artifact_delta:
|
578
|
-
for filename, version in event.actions.artifact_delta.items():
|
579
|
-
artifact_event = _convert_artifact_to_a2a_events(
|
580
|
-
event, invocation_context, filename, version, task_id, context_id
|
581
|
-
)
|
582
|
-
a2a_events.append(artifact_event)
|
583
503
|
|
584
504
|
# Handle error scenarios
|
585
505
|
if event.error_code:
|
@@ -22,8 +22,7 @@ try:
|
|
22
22
|
except ImportError as e:
|
23
23
|
if sys.version_info < (3, 10):
|
24
24
|
raise ImportError(
|
25
|
-
'A2A
|
26
|
-
' version.'
|
25
|
+
'A2A requires Python 3.10 or above. Please upgrade your Python version.'
|
27
26
|
) from e
|
28
27
|
else:
|
29
28
|
raise e
|
@@ -28,8 +28,10 @@ try:
|
|
28
28
|
from a2a.server.agent_execution import AgentExecutor
|
29
29
|
from a2a.server.agent_execution.context import RequestContext
|
30
30
|
from a2a.server.events.event_queue import EventQueue
|
31
|
+
from a2a.types import Artifact
|
31
32
|
from a2a.types import Message
|
32
33
|
from a2a.types import Role
|
34
|
+
from a2a.types import TaskArtifactUpdateEvent
|
33
35
|
from a2a.types import TaskState
|
34
36
|
from a2a.types import TaskStatus
|
35
37
|
from a2a.types import TaskStatusUpdateEvent
|
@@ -218,22 +220,49 @@ class A2aAgentExecutor(AgentExecutor):
|
|
218
220
|
await event_queue.enqueue_event(a2a_event)
|
219
221
|
|
220
222
|
# publish the task result event - this is final
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
223
|
+
if (
|
224
|
+
task_result_aggregator.task_state == TaskState.working
|
225
|
+
and task_result_aggregator.task_status_message is not None
|
226
|
+
and task_result_aggregator.task_status_message.parts
|
227
|
+
):
|
228
|
+
# if task is still working properly, publish the artifact update event as
|
229
|
+
# the final result according to a2a protocol.
|
230
|
+
await event_queue.enqueue_event(
|
231
|
+
TaskArtifactUpdateEvent(
|
232
|
+
taskId=context.task_id,
|
233
|
+
lastChunk=True,
|
234
|
+
contextId=context.context_id,
|
235
|
+
artifact=Artifact(
|
236
|
+
artifactId=str(uuid.uuid4()),
|
237
|
+
parts=task_result_aggregator.task_status_message.parts,
|
238
|
+
),
|
239
|
+
)
|
240
|
+
)
|
241
|
+
# public the final status update event
|
242
|
+
await event_queue.enqueue_event(
|
243
|
+
TaskStatusUpdateEvent(
|
244
|
+
taskId=context.task_id,
|
245
|
+
status=TaskStatus(
|
246
|
+
state=TaskState.completed,
|
247
|
+
timestamp=datetime.now(timezone.utc).isoformat(),
|
248
|
+
),
|
249
|
+
contextId=context.context_id,
|
250
|
+
final=True,
|
251
|
+
)
|
252
|
+
)
|
253
|
+
else:
|
254
|
+
await event_queue.enqueue_event(
|
255
|
+
TaskStatusUpdateEvent(
|
256
|
+
taskId=context.task_id,
|
257
|
+
status=TaskStatus(
|
258
|
+
state=task_result_aggregator.task_state,
|
259
|
+
timestamp=datetime.now(timezone.utc).isoformat(),
|
260
|
+
message=task_result_aggregator.task_status_message,
|
261
|
+
),
|
262
|
+
contextId=context.context_id,
|
263
|
+
final=True,
|
264
|
+
)
|
265
|
+
)
|
237
266
|
|
238
267
|
async def _prepare_session(
|
239
268
|
self, context: RequestContext, run_args: dict[str, Any], runner: Runner
|
google/adk/a2a/logs/log_utils.py
CHANGED
@@ -30,8 +30,7 @@ try:
|
|
30
30
|
except ImportError as e:
|
31
31
|
if sys.version_info < (3, 10):
|
32
32
|
raise ImportError(
|
33
|
-
"A2A
|
34
|
-
" version."
|
33
|
+
"A2A requires Python 3.10 or above. Please upgrade your Python version."
|
35
34
|
) from e
|
36
35
|
else:
|
37
36
|
raise e
|
File without changes
|