google-adk 1.6.1__tar.gz → 1.7.0__tar.gz

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 (273) hide show
  1. {google_adk-1.6.1 → google_adk-1.7.0}/PKG-INFO +2 -2
  2. {google_adk-1.6.1 → google_adk-1.7.0}/pyproject.toml +1 -1
  3. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/converters/event_converter.py +5 -85
  4. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/executor/a2a_agent_executor.py +45 -16
  5. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/__init__.py +5 -0
  6. google_adk-1.7.0/src/google/adk/agents/agent_config.py +46 -0
  7. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/base_agent.py +234 -41
  8. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/callback_context.py +41 -0
  9. google_adk-1.7.0/src/google/adk/agents/common_configs.py +79 -0
  10. google_adk-1.7.0/src/google/adk/agents/config_agent_utils.py +184 -0
  11. google_adk-1.7.0/src/google/adk/agents/config_schemas/AgentConfig.json +544 -0
  12. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/invocation_context.py +5 -1
  13. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/llm_agent.py +190 -9
  14. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/loop_agent.py +29 -0
  15. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/parallel_agent.py +24 -3
  16. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/remote_a2a_agent.py +15 -3
  17. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/sequential_agent.py +22 -1
  18. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/artifacts/gcs_artifact_service.py +24 -2
  19. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/auth_handler.py +3 -3
  20. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/credential_manager.py +23 -23
  21. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/credential_service/base_credential_service.py +6 -6
  22. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/credential_service/in_memory_credential_service.py +10 -8
  23. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/credential_service/session_state_credential_service.py +8 -8
  24. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/exchanger/oauth2_credential_exchanger.py +3 -3
  25. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/oauth2_credential_util.py +2 -2
  26. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/refresher/oauth2_credential_refresher.py +4 -4
  27. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/agent_graph.py +3 -1
  28. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/browser/index.html +1 -1
  29. google_adk-1.7.0/src/google/adk/cli/browser/main-SRBSE46V.js +3914 -0
  30. google_adk-1.7.0/src/google/adk/cli/browser/polyfills-B6TNHZQ6.js +17 -0
  31. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/fast_api.py +42 -2
  32. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/utils/agent_loader.py +35 -1
  33. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/code_executors/base_code_executor.py +14 -19
  34. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/code_executors/built_in_code_executor.py +4 -1
  35. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/base_eval_service.py +46 -2
  36. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/evaluation_generator.py +1 -1
  37. google_adk-1.7.0/src/google/adk/evaluation/in_memory_eval_sets_manager.py +151 -0
  38. google_adk-1.7.0/src/google/adk/evaluation/local_eval_service.py +389 -0
  39. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/local_eval_sets_manager.py +23 -8
  40. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/auto_flow.py +6 -11
  41. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/base_llm_flow.py +41 -23
  42. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/contents.py +16 -10
  43. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/functions.py +76 -33
  44. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/memory/in_memory_memory_service.py +20 -14
  45. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/models/anthropic_llm.py +44 -5
  46. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/models/google_llm.py +11 -6
  47. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/models/lite_llm.py +21 -4
  48. google_adk-1.7.0/src/google/adk/plugins/__init__.py +17 -0
  49. google_adk-1.7.0/src/google/adk/plugins/base_plugin.py +317 -0
  50. google_adk-1.7.0/src/google/adk/plugins/plugin_manager.py +265 -0
  51. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/runners.py +122 -18
  52. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/sessions/database_session_service.py +26 -28
  53. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/sessions/vertex_ai_session_service.py +14 -7
  54. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/agent_tool.py +1 -0
  55. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/apihub_tool/apihub_toolset.py +38 -39
  56. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/application_integration_tool/application_integration_toolset.py +35 -37
  57. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/application_integration_tool/integration_connector_tool.py +2 -3
  58. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/base_tool.py +9 -9
  59. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/base_toolset.py +7 -5
  60. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/bigquery/__init__.py +3 -3
  61. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/enterprise_search_tool.py +4 -2
  62. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/google_api_tool/google_api_tool.py +16 -1
  63. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/google_api_tool/google_api_toolset.py +9 -7
  64. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/google_api_tool/google_api_toolsets.py +41 -20
  65. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/google_search_tool.py +4 -2
  66. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/langchain_tool.py +2 -3
  67. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/long_running_tool.py +21 -0
  68. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/mcp_tool/mcp_toolset.py +27 -28
  69. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/openapi_toolset.py +8 -8
  70. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py +4 -6
  71. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/retrieval/vertex_ai_rag_retrieval.py +3 -2
  72. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/tool_context.py +0 -10
  73. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/url_context_tool.py +4 -2
  74. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/vertex_ai_search_tool.py +4 -2
  75. google_adk-1.7.0/src/google/adk/utils/model_name_utils.py +90 -0
  76. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/version.py +1 -1
  77. google_adk-1.6.1/src/google/adk/cli/browser/main-RXDVX3K6.js +0 -3914
  78. google_adk-1.6.1/src/google/adk/cli/browser/polyfills-FFHMD2TL.js +0 -17
  79. {google_adk-1.6.1 → google_adk-1.7.0}/LICENSE +0 -0
  80. {google_adk-1.6.1 → google_adk-1.7.0}/README.md +0 -0
  81. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/__init__.py +0 -0
  82. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/__init__.py +0 -0
  83. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/converters/__init__.py +0 -0
  84. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/converters/part_converter.py +0 -0
  85. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/converters/request_converter.py +0 -0
  86. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/converters/utils.py +0 -0
  87. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/executor/__init__.py +0 -0
  88. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/executor/task_result_aggregator.py +0 -0
  89. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/logs/__init__.py +0 -0
  90. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/a2a/logs/log_utils.py +0 -0
  91. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/active_streaming_tool.py +0 -0
  92. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/langgraph_agent.py +0 -0
  93. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/live_request_queue.py +0 -0
  94. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/readonly_context.py +0 -0
  95. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/run_config.py +0 -0
  96. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/agents/transcription_entry.py +0 -0
  97. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/artifacts/__init__.py +0 -0
  98. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/artifacts/base_artifact_service.py +0 -0
  99. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/artifacts/in_memory_artifact_service.py +0 -0
  100. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/__init__.py +0 -0
  101. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/auth_credential.py +0 -0
  102. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/auth_preprocessor.py +0 -0
  103. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/auth_schemes.py +0 -0
  104. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/auth_tool.py +0 -0
  105. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/credential_service/__init__.py +0 -0
  106. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/exchanger/__init__.py +0 -0
  107. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/exchanger/base_credential_exchanger.py +0 -0
  108. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/exchanger/credential_exchanger_registry.py +0 -0
  109. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/refresher/__init__.py +0 -0
  110. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/refresher/base_credential_refresher.py +0 -0
  111. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/auth/refresher/credential_refresher_registry.py +0 -0
  112. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/__init__.py +0 -0
  113. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/__main__.py +0 -0
  114. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/browser/adk_favicon.svg +0 -0
  115. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/browser/assets/ADK-512-color.svg +0 -0
  116. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/browser/assets/audio-processor.js +0 -0
  117. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/browser/assets/config/runtime-config.json +0 -0
  118. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/browser/chunk-EQDQRRRY.js +0 -0
  119. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/browser/chunk-TXJFAAIW.js +0 -0
  120. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/browser/styles-4VDSPQ37.css +0 -0
  121. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/cli.py +0 -0
  122. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/cli_create.py +0 -0
  123. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/cli_deploy.py +0 -0
  124. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/cli_eval.py +0 -0
  125. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/cli_tools_click.py +0 -0
  126. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/utils/__init__.py +0 -0
  127. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/utils/cleanup.py +0 -0
  128. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/utils/common.py +0 -0
  129. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/utils/envs.py +0 -0
  130. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/utils/evals.py +0 -0
  131. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/cli/utils/logs.py +0 -0
  132. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/code_executors/__init__.py +0 -0
  133. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/code_executors/code_execution_utils.py +0 -0
  134. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/code_executors/code_executor_context.py +0 -0
  135. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/code_executors/container_code_executor.py +0 -0
  136. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/code_executors/unsafe_local_code_executor.py +0 -0
  137. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/code_executors/vertex_ai_code_executor.py +0 -0
  138. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/errors/__init__.py +0 -0
  139. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/errors/not_found_error.py +0 -0
  140. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/__init__.py +0 -0
  141. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/_eval_set_results_manager_utils.py +0 -0
  142. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/_eval_sets_manager_utils.py +0 -0
  143. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/agent_evaluator.py +0 -0
  144. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/constants.py +0 -0
  145. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/eval_case.py +0 -0
  146. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/eval_metrics.py +0 -0
  147. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/eval_result.py +0 -0
  148. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/eval_set.py +0 -0
  149. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/eval_set_results_manager.py +0 -0
  150. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/eval_sets_manager.py +0 -0
  151. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/evaluation_constants.py +0 -0
  152. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/evaluator.py +0 -0
  153. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/final_response_match_v1.py +0 -0
  154. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/final_response_match_v2.py +0 -0
  155. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/gcs_eval_set_results_manager.py +0 -0
  156. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/gcs_eval_sets_manager.py +0 -0
  157. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/llm_as_judge.py +0 -0
  158. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/llm_as_judge_utils.py +0 -0
  159. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/local_eval_set_results_manager.py +0 -0
  160. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/metric_evaluator_registry.py +0 -0
  161. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/response_evaluator.py +0 -0
  162. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/safety_evaluator.py +0 -0
  163. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/trajectory_evaluator.py +0 -0
  164. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/evaluation/vertex_ai_eval_facade.py +0 -0
  165. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/events/__init__.py +0 -0
  166. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/events/event.py +0 -0
  167. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/events/event_actions.py +0 -0
  168. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/examples/__init__.py +0 -0
  169. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/examples/base_example_provider.py +0 -0
  170. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/examples/example.py +0 -0
  171. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/examples/example_util.py +0 -0
  172. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/examples/vertex_ai_example_store.py +0 -0
  173. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/__init__.py +0 -0
  174. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/__init__.py +0 -0
  175. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/_base_llm_processor.py +0 -0
  176. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/_code_execution.py +0 -0
  177. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/_nl_planning.py +0 -0
  178. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/agent_transfer.py +0 -0
  179. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/audio_transcriber.py +0 -0
  180. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/basic.py +0 -0
  181. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/identity.py +0 -0
  182. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/instructions.py +0 -0
  183. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/flows/llm_flows/single_flow.py +0 -0
  184. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/memory/__init__.py +0 -0
  185. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/memory/_utils.py +0 -0
  186. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/memory/base_memory_service.py +0 -0
  187. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/memory/memory_entry.py +0 -0
  188. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/memory/vertex_ai_memory_bank_service.py +0 -0
  189. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/memory/vertex_ai_rag_memory_service.py +0 -0
  190. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/models/__init__.py +0 -0
  191. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/models/base_llm.py +0 -0
  192. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/models/base_llm_connection.py +0 -0
  193. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/models/gemini_llm_connection.py +0 -0
  194. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/models/llm_request.py +0 -0
  195. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/models/llm_response.py +0 -0
  196. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/models/registry.py +0 -0
  197. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/planners/__init__.py +0 -0
  198. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/planners/base_planner.py +0 -0
  199. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/planners/built_in_planner.py +0 -0
  200. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/planners/plan_re_act_planner.py +0 -0
  201. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/platform/__init__.py +0 -0
  202. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/platform/internal/__init__.py +0 -0
  203. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/platform/internal/thread.py +0 -0
  204. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/platform/thread.py +0 -0
  205. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/py.typed +0 -0
  206. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/sessions/__init__.py +0 -0
  207. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/sessions/_session_util.py +0 -0
  208. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/sessions/base_session_service.py +0 -0
  209. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/sessions/in_memory_session_service.py +0 -0
  210. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/sessions/session.py +0 -0
  211. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/sessions/state.py +0 -0
  212. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/telemetry.py +0 -0
  213. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/__init__.py +0 -0
  214. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/_automatic_function_calling_util.py +0 -0
  215. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/_forwarding_artifact_service.py +0 -0
  216. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/_function_parameter_parse_util.py +0 -0
  217. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/_gemini_schema_util.py +0 -0
  218. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/_memory_entry_utils.py +0 -0
  219. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/apihub_tool/__init__.py +0 -0
  220. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/apihub_tool/clients/__init__.py +0 -0
  221. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/apihub_tool/clients/apihub_client.py +0 -0
  222. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/apihub_tool/clients/secret_client.py +0 -0
  223. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/application_integration_tool/__init__.py +0 -0
  224. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/application_integration_tool/clients/connections_client.py +0 -0
  225. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/application_integration_tool/clients/integration_client.py +0 -0
  226. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/authenticated_function_tool.py +0 -0
  227. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/base_authenticated_tool.py +0 -0
  228. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/bigquery/bigquery_credentials.py +0 -0
  229. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/bigquery/bigquery_tool.py +0 -0
  230. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/bigquery/bigquery_toolset.py +0 -0
  231. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/bigquery/client.py +0 -0
  232. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/bigquery/config.py +0 -0
  233. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/bigquery/metadata_tool.py +0 -0
  234. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/bigquery/query_tool.py +0 -0
  235. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/crewai_tool.py +0 -0
  236. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/example_tool.py +0 -0
  237. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/exit_loop_tool.py +0 -0
  238. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/function_tool.py +0 -0
  239. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/get_user_choice_tool.py +0 -0
  240. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/google_api_tool/__init__.py +0 -0
  241. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/google_api_tool/googleapi_to_openapi_converter.py +0 -0
  242. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/load_artifacts_tool.py +0 -0
  243. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/load_memory_tool.py +0 -0
  244. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/load_web_page.py +0 -0
  245. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/mcp_tool/__init__.py +0 -0
  246. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/mcp_tool/conversion_utils.py +0 -0
  247. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/mcp_tool/mcp_session_manager.py +0 -0
  248. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/mcp_tool/mcp_tool.py +0 -0
  249. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/__init__.py +0 -0
  250. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/auth/__init__.py +0 -0
  251. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/auth/auth_helpers.py +0 -0
  252. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/auth/credential_exchangers/__init__.py +0 -0
  253. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.py +0 -0
  254. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/auth/credential_exchangers/base_credential_exchanger.py +0 -0
  255. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.py +0 -0
  256. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.py +0 -0
  257. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/common/__init__.py +0 -0
  258. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/common/common.py +0 -0
  259. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/__init__.py +0 -0
  260. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.py +0 -0
  261. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/operation_parser.py +0 -0
  262. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.py +0 -0
  263. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/preload_memory_tool.py +0 -0
  264. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/retrieval/__init__.py +0 -0
  265. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/retrieval/base_retrieval_tool.py +0 -0
  266. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/retrieval/files_retrieval.py +0 -0
  267. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/retrieval/llama_index_retrieval.py +0 -0
  268. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/toolbox_toolset.py +0 -0
  269. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/tools/transfer_to_agent_tool.py +0 -0
  270. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/utils/__init__.py +0 -0
  271. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/utils/feature_decorator.py +0 -0
  272. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/utils/instructions_utils.py +0 -0
  273. {google_adk-1.6.1 → google_adk-1.7.0}/src/google/adk/utils/variant_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-adk
3
- Version: 1.6.1
3
+ Version: 1.7.0
4
4
  Summary: Agent Development Kit
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  Requires-Python: >=3.9
@@ -47,7 +47,7 @@ Requires-Dist: tzlocal>=5.3
47
47
  Requires-Dist: uvicorn>=0.34.0
48
48
  Requires-Dist: watchdog>=6.0.0
49
49
  Requires-Dist: websockets>=15.0.1
50
- Requires-Dist: a2a-sdk>=0.2.7 ; extra == "a2a" and (python_version>='3.10')
50
+ Requires-Dist: a2a-sdk>=0.2.11 ; extra == "a2a" and (python_version>='3.10')
51
51
  Requires-Dist: flit>=3.10.0 ; extra == "dev"
52
52
  Requires-Dist: isort>=6.0.0 ; extra == "dev"
53
53
  Requires-Dist: mypy>=1.15.0 ; extra == "dev"
@@ -80,7 +80,7 @@ dev = [
80
80
 
81
81
  a2a = [
82
82
  # go/keep-sorted start
83
- "a2a-sdk>=0.2.7;python_version>='3.10'"
83
+ "a2a-sdk>=0.2.11;python_version>='3.10'"
84
84
  # go/keep-sorted end
85
85
  ]
86
86
 
@@ -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.status and a2a_task.status.message:
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:
@@ -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
- await event_queue.enqueue_event(
222
- TaskStatusUpdateEvent(
223
- taskId=context.task_id,
224
- status=TaskStatus(
225
- state=(
226
- task_result_aggregator.task_state
227
- if task_result_aggregator.task_state != TaskState.working
228
- else TaskState.completed
229
- ),
230
- timestamp=datetime.now(timezone.utc).isoformat(),
231
- message=task_result_aggregator.task_status_message,
232
- ),
233
- contextId=context.context_id,
234
- final=True,
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
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  from .base_agent import BaseAgent
16
+ from .invocation_context import InvocationContext
16
17
  from .live_request_queue import LiveRequest
17
18
  from .live_request_queue import LiveRequestQueue
18
19
  from .llm_agent import Agent
@@ -29,4 +30,8 @@ __all__ = [
29
30
  'LoopAgent',
30
31
  'ParallelAgent',
31
32
  'SequentialAgent',
33
+ 'InvocationContext',
34
+ 'LiveRequest',
35
+ 'LiveRequestQueue',
36
+ 'RunConfig',
32
37
  ]
@@ -0,0 +1,46 @@
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
+ from typing import Union
18
+
19
+ from pydantic import RootModel
20
+
21
+ from ..utils.feature_decorator import working_in_progress
22
+ from .llm_agent import LlmAgentConfig
23
+ from .loop_agent import LoopAgentConfig
24
+ from .parallel_agent import ParallelAgentConfig
25
+ from .sequential_agent import SequentialAgentConfig
26
+
27
+ # A discriminated union of all possible agent configurations.
28
+ ConfigsUnion = Union[
29
+ LlmAgentConfig,
30
+ LoopAgentConfig,
31
+ ParallelAgentConfig,
32
+ SequentialAgentConfig,
33
+ ]
34
+
35
+
36
+ # Use a RootModel to represent the agent directly at the top level.
37
+ # The `discriminator` is applied to the union within the RootModel.
38
+ @working_in_progress("AgentConfig is not ready for use.")
39
+ class AgentConfig(RootModel[ConfigsUnion]):
40
+ """The config for the YAML schema to create an agent."""
41
+
42
+ class Config:
43
+ # Pydantic v2 requires this for discriminated unions on RootModel
44
+ # This tells the model to look at the 'agent_class' field of the input
45
+ # data to decide which model from the `ConfigsUnion` to use.
46
+ discriminator = "agent_class"
@@ -19,9 +19,13 @@ from typing import Any
19
19
  from typing import AsyncGenerator
20
20
  from typing import Awaitable
21
21
  from typing import Callable
22
+ from typing import Dict
22
23
  from typing import final
24
+ from typing import List
25
+ from typing import Literal
23
26
  from typing import Mapping
24
27
  from typing import Optional
28
+ from typing import Type
25
29
  from typing import TYPE_CHECKING
26
30
  from typing import TypeVar
27
31
  from typing import Union
@@ -32,11 +36,14 @@ from pydantic import BaseModel
32
36
  from pydantic import ConfigDict
33
37
  from pydantic import Field
34
38
  from pydantic import field_validator
39
+ from pydantic import model_validator
35
40
  from typing_extensions import override
36
41
  from typing_extensions import TypeAlias
37
42
 
38
43
  from ..events.event import Event
44
+ from ..utils.feature_decorator import working_in_progress
39
45
  from .callback_context import CallbackContext
46
+ from .common_configs import CodeConfig
40
47
 
41
48
  if TYPE_CHECKING:
42
49
  from .invocation_context import InvocationContext
@@ -223,11 +230,18 @@ class BaseAgent(BaseModel):
223
230
  """
224
231
  with tracer.start_as_current_span(f'agent_run [{self.name}]'):
225
232
  ctx = self._create_invocation_context(parent_context)
226
- # TODO(hangfei): support before/after_agent_callback
233
+
234
+ if event := await self.__handle_before_agent_callback(ctx):
235
+ yield event
236
+ if ctx.end_invocation:
237
+ return
227
238
 
228
239
  async for event in self._run_live_impl(ctx):
229
240
  yield event
230
241
 
242
+ if event := await self.__handle_after_agent_callback(ctx):
243
+ yield event
244
+
231
245
  async def _run_async_impl(
232
246
  self, ctx: InvocationContext
233
247
  ) -> AsyncGenerator[Event, None]:
@@ -331,73 +345,99 @@ class BaseAgent(BaseModel):
331
345
  ) -> Optional[Event]:
332
346
  """Runs the before_agent_callback if it exists.
333
347
 
348
+ Args:
349
+ ctx: InvocationContext, the invocation context for this agent.
350
+
334
351
  Returns:
335
352
  Optional[Event]: an event if callback provides content or changed state.
336
353
  """
337
- ret_event = None
338
-
339
- if not self.canonical_before_agent_callbacks:
340
- return ret_event
341
-
342
354
  callback_context = CallbackContext(ctx)
343
355
 
344
- for callback in self.canonical_before_agent_callbacks:
345
- before_agent_callback_content = callback(
346
- callback_context=callback_context
347
- )
348
- if inspect.isawaitable(before_agent_callback_content):
349
- before_agent_callback_content = await before_agent_callback_content
350
- if before_agent_callback_content:
351
- ret_event = Event(
352
- invocation_id=ctx.invocation_id,
353
- author=self.name,
354
- branch=ctx.branch,
355
- content=before_agent_callback_content,
356
- actions=callback_context._event_actions,
356
+ # Run callbacks from the plugins.
357
+ before_agent_callback_content = (
358
+ await ctx.plugin_manager.run_before_agent_callback(
359
+ agent=self, callback_context=callback_context
357
360
  )
358
- ctx.end_invocation = True
359
- return ret_event
361
+ )
360
362
 
361
- if callback_context.state.has_delta():
363
+ # If no overrides are provided from the plugins, further run the canonical
364
+ # callbacks.
365
+ if (
366
+ not before_agent_callback_content
367
+ and self.canonical_before_agent_callbacks
368
+ ):
369
+ for callback in self.canonical_before_agent_callbacks:
370
+ before_agent_callback_content = callback(
371
+ callback_context=callback_context
372
+ )
373
+ if inspect.isawaitable(before_agent_callback_content):
374
+ before_agent_callback_content = await before_agent_callback_content
375
+ if before_agent_callback_content:
376
+ break
377
+
378
+ # Process the override content if exists, and further process the state
379
+ # change if exists.
380
+ if before_agent_callback_content:
362
381
  ret_event = Event(
382
+ invocation_id=ctx.invocation_id,
383
+ author=self.name,
384
+ branch=ctx.branch,
385
+ content=before_agent_callback_content,
386
+ actions=callback_context._event_actions,
387
+ )
388
+ ctx.end_invocation = True
389
+ return ret_event
390
+
391
+ if callback_context.state.has_delta():
392
+ return Event(
363
393
  invocation_id=ctx.invocation_id,
364
394
  author=self.name,
365
395
  branch=ctx.branch,
366
396
  actions=callback_context._event_actions,
367
397
  )
368
398
 
369
- return ret_event
399
+ return None
370
400
 
371
401
  async def __handle_after_agent_callback(
372
402
  self, invocation_context: InvocationContext
373
403
  ) -> Optional[Event]:
374
404
  """Runs the after_agent_callback if it exists.
375
405
 
406
+ Args:
407
+ invocation_context: InvocationContext, the invocation context for this
408
+ agent.
409
+
376
410
  Returns:
377
411
  Optional[Event]: an event if callback provides content or changed state.
378
412
  """
379
- ret_event = None
380
-
381
- if not self.canonical_after_agent_callbacks:
382
- return ret_event
383
413
 
384
414
  callback_context = CallbackContext(invocation_context)
385
415
 
386
- for callback in self.canonical_after_agent_callbacks:
387
- after_agent_callback_content = callback(callback_context=callback_context)
388
- if inspect.isawaitable(after_agent_callback_content):
389
- after_agent_callback_content = await after_agent_callback_content
390
- if after_agent_callback_content:
391
- ret_event = Event(
392
- invocation_id=invocation_context.invocation_id,
393
- author=self.name,
394
- branch=invocation_context.branch,
395
- content=after_agent_callback_content,
396
- actions=callback_context._event_actions,
416
+ # Run callbacks from the plugins.
417
+ after_agent_callback_content = (
418
+ await invocation_context.plugin_manager.run_after_agent_callback(
419
+ agent=self, callback_context=callback_context
397
420
  )
398
- return ret_event
421
+ )
399
422
 
400
- if callback_context.state.has_delta():
423
+ # If no overrides are provided from the plugins, further run the canonical
424
+ # callbacks.
425
+ if (
426
+ not after_agent_callback_content
427
+ and self.canonical_after_agent_callbacks
428
+ ):
429
+ for callback in self.canonical_after_agent_callbacks:
430
+ after_agent_callback_content = callback(
431
+ callback_context=callback_context
432
+ )
433
+ if inspect.isawaitable(after_agent_callback_content):
434
+ after_agent_callback_content = await after_agent_callback_content
435
+ if after_agent_callback_content:
436
+ break
437
+
438
+ # Process the override content if exists, and further process the state
439
+ # change if exists.
440
+ if after_agent_callback_content:
401
441
  ret_event = Event(
402
442
  invocation_id=invocation_context.invocation_id,
403
443
  author=self.name,
@@ -405,8 +445,17 @@ class BaseAgent(BaseModel):
405
445
  content=after_agent_callback_content,
406
446
  actions=callback_context._event_actions,
407
447
  )
448
+ return ret_event
408
449
 
409
- return ret_event
450
+ if callback_context.state.has_delta():
451
+ return Event(
452
+ invocation_id=invocation_context.invocation_id,
453
+ author=self.name,
454
+ branch=invocation_context.branch,
455
+ content=after_agent_callback_content,
456
+ actions=callback_context._event_actions,
457
+ )
458
+ return None
410
459
 
411
460
  @override
412
461
  def model_post_init(self, __context: Any) -> None:
@@ -439,3 +488,147 @@ class BaseAgent(BaseModel):
439
488
  )
440
489
  sub_agent.parent_agent = self
441
490
  return self
491
+
492
+ @classmethod
493
+ @working_in_progress('BaseAgent.from_config is not ready for use.')
494
+ def from_config(
495
+ cls: Type[SelfAgent],
496
+ config: BaseAgentConfig,
497
+ config_abs_path: str,
498
+ ) -> SelfAgent:
499
+ """Creates an agent from a config.
500
+
501
+ This method converts fields in a config to the corresponding
502
+ fields in an agent.
503
+
504
+ Child classes should re-implement this method to support loading from their
505
+ custom config types.
506
+
507
+ Args:
508
+ config: The config to create the agent from.
509
+
510
+ Returns:
511
+ The created agent.
512
+ """
513
+ from .config_agent_utils import build_sub_agent
514
+ from .config_agent_utils import resolve_callbacks
515
+
516
+ kwargs: Dict[str, Any] = {
517
+ 'name': config.name,
518
+ 'description': config.description,
519
+ }
520
+ if config.sub_agents:
521
+ sub_agents = []
522
+ for sub_agent_config in config.sub_agents:
523
+ sub_agent = build_sub_agent(
524
+ sub_agent_config, config_abs_path.rsplit('/', 1)[0]
525
+ )
526
+ sub_agents.append(sub_agent)
527
+ kwargs['sub_agents'] = sub_agents
528
+
529
+ if config.before_agent_callbacks:
530
+ kwargs['before_agent_callback'] = resolve_callbacks(
531
+ config.before_agent_callbacks
532
+ )
533
+ if config.after_agent_callbacks:
534
+ kwargs['after_agent_callback'] = resolve_callbacks(
535
+ config.after_agent_callbacks
536
+ )
537
+ return cls(**kwargs)
538
+
539
+
540
+ class SubAgentConfig(BaseModel):
541
+ """The config for a sub-agent."""
542
+
543
+ model_config = ConfigDict(extra='forbid')
544
+
545
+ config: Optional[str] = None
546
+ """The YAML config file path of the sub-agent.
547
+
548
+ Only one of `config` or `code` can be set.
549
+
550
+ Example:
551
+
552
+ ```
553
+ sub_agents:
554
+ - config: search_agent.yaml
555
+ - config: my_library/my_custom_agent.yaml
556
+ ```
557
+ """
558
+
559
+ code: Optional[str] = None
560
+ """The agent instance defined in the code.
561
+
562
+ Only one of `config` or `code` can be set.
563
+
564
+ Example:
565
+
566
+ For the following agent defined in Python code:
567
+
568
+ ```
569
+ # my_library/custom_agents.py
570
+ from google.adk.agents import LlmAgent
571
+
572
+ my_custom_agent = LlmAgent(
573
+ name="my_custom_agent",
574
+ instruction="You are a helpful custom agent.",
575
+ model="gemini-2.0-flash",
576
+ )
577
+ ```
578
+
579
+ The yaml config should be:
580
+
581
+ ```
582
+ sub_agents:
583
+ - code: my_library.custom_agents.my_custom_agent
584
+ ```
585
+ """
586
+
587
+ @model_validator(mode='after')
588
+ def validate_exactly_one_field(self):
589
+ code_provided = self.code is not None
590
+ config_provided = self.config is not None
591
+
592
+ if code_provided and config_provided:
593
+ raise ValueError('Only one of code or config should be provided')
594
+ if not code_provided and not config_provided:
595
+ raise ValueError('Exactly one of code or config must be provided')
596
+
597
+ return self
598
+
599
+
600
+ @working_in_progress('BaseAgentConfig is not ready for use.')
601
+ class BaseAgentConfig(BaseModel):
602
+ """The config for the YAML schema of a BaseAgent.
603
+
604
+ Do not use this class directly. It's the base class for all agent configs.
605
+ """
606
+
607
+ model_config = ConfigDict(extra='forbid')
608
+
609
+ agent_class: Literal['BaseAgent'] = 'BaseAgent'
610
+ """Required. The class of the agent. The value is used to differentiate
611
+ among different agent classes."""
612
+
613
+ name: str
614
+ """Required. The name of the agent."""
615
+
616
+ description: str = ''
617
+ """Optional. The description of the agent."""
618
+
619
+ sub_agents: Optional[List[SubAgentConfig]] = None
620
+ """Optional. The sub-agents of the agent."""
621
+
622
+ before_agent_callbacks: Optional[List[CodeConfig]] = None
623
+ """Optional. The before_agent_callbacks of the agent.
624
+
625
+ Example:
626
+
627
+ ```
628
+ before_agent_callbacks:
629
+ - name: my_library.security_callbacks.before_agent_callback
630
+ ```
631
+ """
632
+
633
+ after_agent_callbacks: Optional[List[CodeConfig]] = None
634
+ """Optional. The after_agent_callbacks of the agent."""
@@ -24,6 +24,8 @@ from .readonly_context import ReadonlyContext
24
24
  if TYPE_CHECKING:
25
25
  from google.genai import types
26
26
 
27
+ from ..auth.auth_credential import AuthCredential
28
+ from ..auth.auth_tool import AuthConfig
27
29
  from ..events.event_actions import EventActions
28
30
  from ..sessions.state import State
29
31
  from .invocation_context import InvocationContext
@@ -105,3 +107,42 @@ class CallbackContext(ReadonlyContext):
105
107
  )
106
108
  self._event_actions.artifact_delta[filename] = version
107
109
  return version
110
+
111
+ async def list_artifacts(self) -> list[str]:
112
+ """Lists the filenames of the artifacts attached to the current session."""
113
+ if self._invocation_context.artifact_service is None:
114
+ raise ValueError("Artifact service is not initialized.")
115
+ return await self._invocation_context.artifact_service.list_artifact_keys(
116
+ app_name=self._invocation_context.app_name,
117
+ user_id=self._invocation_context.user_id,
118
+ session_id=self._invocation_context.session.id,
119
+ )
120
+
121
+ async def save_credential(self, auth_config: AuthConfig) -> None:
122
+ """Saves a credential to the credential service.
123
+
124
+ Args:
125
+ auth_config: The authentication configuration containing the credential.
126
+ """
127
+ if self._invocation_context.credential_service is None:
128
+ raise ValueError("Credential service is not initialized.")
129
+ await self._invocation_context.credential_service.save_credential(
130
+ auth_config, self
131
+ )
132
+
133
+ async def load_credential(
134
+ self, auth_config: AuthConfig
135
+ ) -> Optional[AuthCredential]:
136
+ """Loads a credential from the credential service.
137
+
138
+ Args:
139
+ auth_config: The authentication configuration for the credential.
140
+
141
+ Returns:
142
+ The loaded credential, or None if not found.
143
+ """
144
+ if self._invocation_context.credential_service is None:
145
+ raise ValueError("Credential service is not initialized.")
146
+ return await self._invocation_context.credential_service.load_credential(
147
+ auth_config, self
148
+ )