google-adk 0.0.2__py3-none-any.whl → 0.0.4__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 (153) hide show
  1. google/adk/agents/run_config.py +4 -0
  2. google/adk/auth/auth_preprocessor.py +19 -16
  3. google/adk/cli/agent_graph.py +31 -5
  4. google/adk/cli/browser/index.html +1 -1
  5. google/adk/cli/browser/{main-XUU6OGCC.js → main-CU22TRPI.js} +30 -30
  6. google/adk/cli/cli.py +8 -8
  7. google/adk/cli/cli_deploy.py +2 -4
  8. google/adk/cli/cli_tools_click.py +57 -12
  9. google/adk/cli/fast_api.py +19 -9
  10. google/adk/flows/llm_flows/contents.py +21 -1
  11. google/adk/flows/llm_flows/functions.py +3 -1
  12. google/adk/models/google_llm.py +0 -1
  13. google/adk/runners.py +13 -2
  14. google/adk/version.py +1 -1
  15. {google_adk-0.0.2.dist-info → google_adk-0.0.4.dist-info}/METADATA +4 -2
  16. google_adk-0.0.4.dist-info/RECORD +175 -0
  17. {google_adk-0.0.2.dist-info → google_adk-0.0.4.dist-info}/WHEEL +1 -1
  18. google/adk/cli/media_streamer/__init__.py +0 -19
  19. google/adk/cli/media_streamer/index.html +0 -228
  20. google/adk/tests/__init__.py +0 -14
  21. google/adk/tests/integration/.env.example +0 -10
  22. google/adk/tests/integration/__init__.py +0 -18
  23. google/adk/tests/integration/conftest.py +0 -119
  24. google/adk/tests/integration/fixture/__init__.py +0 -14
  25. google/adk/tests/integration/fixture/agent_with_config/__init__.py +0 -15
  26. google/adk/tests/integration/fixture/agent_with_config/agent.py +0 -88
  27. google/adk/tests/integration/fixture/callback_agent/__init__.py +0 -15
  28. google/adk/tests/integration/fixture/callback_agent/agent.py +0 -105
  29. google/adk/tests/integration/fixture/context_update_test/OWNERS +0 -1
  30. google/adk/tests/integration/fixture/context_update_test/__init__.py +0 -15
  31. google/adk/tests/integration/fixture/context_update_test/agent.py +0 -43
  32. google/adk/tests/integration/fixture/context_update_test/successful_test.session.json +0 -582
  33. google/adk/tests/integration/fixture/context_variable_agent/__init__.py +0 -15
  34. google/adk/tests/integration/fixture/context_variable_agent/agent.py +0 -115
  35. google/adk/tests/integration/fixture/customer_support_ma/__init__.py +0 -15
  36. google/adk/tests/integration/fixture/customer_support_ma/agent.py +0 -172
  37. google/adk/tests/integration/fixture/ecommerce_customer_service_agent/__init__.py +0 -15
  38. google/adk/tests/integration/fixture/ecommerce_customer_service_agent/agent.py +0 -338
  39. google/adk/tests/integration/fixture/ecommerce_customer_service_agent/order_query.test.json +0 -69
  40. google/adk/tests/integration/fixture/ecommerce_customer_service_agent/test_config.json +0 -6
  41. google/adk/tests/integration/fixture/flow_complex_spark/__init__.py +0 -15
  42. google/adk/tests/integration/fixture/flow_complex_spark/agent.py +0 -182
  43. google/adk/tests/integration/fixture/flow_complex_spark/sample.debug.log +0 -243
  44. google/adk/tests/integration/fixture/flow_complex_spark/sample.session.json +0 -190
  45. google/adk/tests/integration/fixture/hello_world_agent/__init__.py +0 -15
  46. google/adk/tests/integration/fixture/hello_world_agent/agent.py +0 -95
  47. google/adk/tests/integration/fixture/hello_world_agent/roll_die.test.json +0 -24
  48. google/adk/tests/integration/fixture/hello_world_agent/test_config.json +0 -6
  49. google/adk/tests/integration/fixture/home_automation_agent/__init__.py +0 -15
  50. google/adk/tests/integration/fixture/home_automation_agent/agent.py +0 -304
  51. google/adk/tests/integration/fixture/home_automation_agent/simple_test.test.json +0 -5
  52. google/adk/tests/integration/fixture/home_automation_agent/simple_test2.test.json +0 -5
  53. google/adk/tests/integration/fixture/home_automation_agent/test_config.json +0 -5
  54. google/adk/tests/integration/fixture/home_automation_agent/test_files/dependent_tool_calls.test.json +0 -18
  55. google/adk/tests/integration/fixture/home_automation_agent/test_files/memorizing_past_events/eval_data.test.json +0 -17
  56. google/adk/tests/integration/fixture/home_automation_agent/test_files/memorizing_past_events/test_config.json +0 -6
  57. google/adk/tests/integration/fixture/home_automation_agent/test_files/simple_multi_turn_conversation.test.json +0 -18
  58. google/adk/tests/integration/fixture/home_automation_agent/test_files/simple_test.test.json +0 -17
  59. google/adk/tests/integration/fixture/home_automation_agent/test_files/simple_test2.test.json +0 -5
  60. google/adk/tests/integration/fixture/home_automation_agent/test_files/test_config.json +0 -5
  61. google/adk/tests/integration/fixture/tool_agent/__init__.py +0 -15
  62. google/adk/tests/integration/fixture/tool_agent/agent.py +0 -218
  63. google/adk/tests/integration/fixture/tool_agent/files/Agent_test_plan.pdf +0 -0
  64. google/adk/tests/integration/fixture/trip_planner_agent/__init__.py +0 -15
  65. google/adk/tests/integration/fixture/trip_planner_agent/agent.py +0 -110
  66. google/adk/tests/integration/fixture/trip_planner_agent/initial.session.json +0 -13
  67. google/adk/tests/integration/fixture/trip_planner_agent/test_config.json +0 -5
  68. google/adk/tests/integration/fixture/trip_planner_agent/test_files/initial.session.json +0 -13
  69. google/adk/tests/integration/fixture/trip_planner_agent/test_files/test_config.json +0 -5
  70. google/adk/tests/integration/fixture/trip_planner_agent/test_files/trip_inquiry_sub_agent.test.json +0 -7
  71. google/adk/tests/integration/fixture/trip_planner_agent/trip_inquiry.test.json +0 -19
  72. google/adk/tests/integration/models/__init__.py +0 -14
  73. google/adk/tests/integration/models/test_google_llm.py +0 -65
  74. google/adk/tests/integration/test_callback.py +0 -70
  75. google/adk/tests/integration/test_context_variable.py +0 -67
  76. google/adk/tests/integration/test_evalute_agent_in_fixture.py +0 -76
  77. google/adk/tests/integration/test_multi_agent.py +0 -28
  78. google/adk/tests/integration/test_multi_turn.py +0 -42
  79. google/adk/tests/integration/test_single_agent.py +0 -23
  80. google/adk/tests/integration/test_sub_agent.py +0 -26
  81. google/adk/tests/integration/test_system_instruction.py +0 -177
  82. google/adk/tests/integration/test_tools.py +0 -287
  83. google/adk/tests/integration/test_with_test_file.py +0 -34
  84. google/adk/tests/integration/tools/__init__.py +0 -14
  85. google/adk/tests/integration/utils/__init__.py +0 -16
  86. google/adk/tests/integration/utils/asserts.py +0 -75
  87. google/adk/tests/integration/utils/test_runner.py +0 -97
  88. google/adk/tests/unittests/__init__.py +0 -14
  89. google/adk/tests/unittests/agents/__init__.py +0 -14
  90. google/adk/tests/unittests/agents/test_base_agent.py +0 -407
  91. google/adk/tests/unittests/agents/test_langgraph_agent.py +0 -191
  92. google/adk/tests/unittests/agents/test_llm_agent_callbacks.py +0 -138
  93. google/adk/tests/unittests/agents/test_llm_agent_fields.py +0 -231
  94. google/adk/tests/unittests/agents/test_loop_agent.py +0 -136
  95. google/adk/tests/unittests/agents/test_parallel_agent.py +0 -92
  96. google/adk/tests/unittests/agents/test_sequential_agent.py +0 -114
  97. google/adk/tests/unittests/artifacts/__init__.py +0 -14
  98. google/adk/tests/unittests/artifacts/test_artifact_service.py +0 -276
  99. google/adk/tests/unittests/auth/test_auth_handler.py +0 -575
  100. google/adk/tests/unittests/conftest.py +0 -73
  101. google/adk/tests/unittests/fast_api/__init__.py +0 -14
  102. google/adk/tests/unittests/fast_api/test_fast_api.py +0 -269
  103. google/adk/tests/unittests/flows/__init__.py +0 -14
  104. google/adk/tests/unittests/flows/llm_flows/__init__.py +0 -14
  105. google/adk/tests/unittests/flows/llm_flows/_test_examples.py +0 -142
  106. google/adk/tests/unittests/flows/llm_flows/test_agent_transfer.py +0 -311
  107. google/adk/tests/unittests/flows/llm_flows/test_functions_long_running.py +0 -244
  108. google/adk/tests/unittests/flows/llm_flows/test_functions_request_euc.py +0 -346
  109. google/adk/tests/unittests/flows/llm_flows/test_functions_sequential.py +0 -93
  110. google/adk/tests/unittests/flows/llm_flows/test_functions_simple.py +0 -258
  111. google/adk/tests/unittests/flows/llm_flows/test_identity.py +0 -66
  112. google/adk/tests/unittests/flows/llm_flows/test_instructions.py +0 -164
  113. google/adk/tests/unittests/flows/llm_flows/test_model_callbacks.py +0 -142
  114. google/adk/tests/unittests/flows/llm_flows/test_other_configs.py +0 -46
  115. google/adk/tests/unittests/flows/llm_flows/test_tool_callbacks.py +0 -269
  116. google/adk/tests/unittests/models/__init__.py +0 -14
  117. google/adk/tests/unittests/models/test_google_llm.py +0 -224
  118. google/adk/tests/unittests/models/test_litellm.py +0 -804
  119. google/adk/tests/unittests/models/test_models.py +0 -60
  120. google/adk/tests/unittests/sessions/__init__.py +0 -14
  121. google/adk/tests/unittests/sessions/test_session_service.py +0 -227
  122. google/adk/tests/unittests/sessions/test_vertex_ai_session_service.py +0 -246
  123. google/adk/tests/unittests/streaming/__init__.py +0 -14
  124. google/adk/tests/unittests/streaming/test_streaming.py +0 -50
  125. google/adk/tests/unittests/tools/__init__.py +0 -14
  126. google/adk/tests/unittests/tools/apihub_tool/clients/test_apihub_client.py +0 -499
  127. google/adk/tests/unittests/tools/apihub_tool/test_apihub_toolset.py +0 -204
  128. google/adk/tests/unittests/tools/application_integration_tool/clients/test_connections_client.py +0 -600
  129. google/adk/tests/unittests/tools/application_integration_tool/clients/test_integration_client.py +0 -630
  130. google/adk/tests/unittests/tools/application_integration_tool/test_application_integration_toolset.py +0 -345
  131. google/adk/tests/unittests/tools/google_api_tool/__init__.py +0 -13
  132. google/adk/tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py +0 -657
  133. google/adk/tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_auto_auth_credential_exchanger.py +0 -145
  134. google/adk/tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_base_auth_credential_exchanger.py +0 -68
  135. google/adk/tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_oauth2_exchanger.py +0 -153
  136. google/adk/tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_service_account_exchanger.py +0 -196
  137. google/adk/tests/unittests/tools/openapi_tool/auth/test_auth_helper.py +0 -573
  138. google/adk/tests/unittests/tools/openapi_tool/common/test_common.py +0 -436
  139. google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test.yaml +0 -1367
  140. google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_spec_parser.py +0 -628
  141. google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_toolset.py +0 -139
  142. google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_operation_parser.py +0 -406
  143. google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_rest_api_tool.py +0 -966
  144. google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_tool_auth_handler.py +0 -201
  145. google/adk/tests/unittests/tools/retrieval/__init__.py +0 -14
  146. google/adk/tests/unittests/tools/retrieval/test_vertex_ai_rag_retrieval.py +0 -147
  147. google/adk/tests/unittests/tools/test_agent_tool.py +0 -167
  148. google/adk/tests/unittests/tools/test_base_tool.py +0 -141
  149. google/adk/tests/unittests/tools/test_build_function_declaration.py +0 -277
  150. google/adk/tests/unittests/utils.py +0 -304
  151. google_adk-0.0.2.dist-info/RECORD +0 -308
  152. {google_adk-0.0.2.dist-info → google_adk-0.0.4.dist-info}/entry_points.txt +0 -0
  153. {google_adk-0.0.2.dist-info → google_adk-0.0.4.dist-info/licenses}/LICENSE +0 -0
@@ -1,70 +0,0 @@
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 pytest import mark
16
-
17
- from ..unittests.utils import simplify_events
18
- from .fixture import callback_agent
19
- from .utils import assert_agent_says
20
- from .utils import TestRunner
21
-
22
-
23
- @mark.parametrize(
24
- "agent_runner",
25
- [{"agent": callback_agent.agent.before_agent_callback_agent}],
26
- indirect=True,
27
- )
28
- def test_before_agent_call(agent_runner: TestRunner):
29
- agent_runner.run("Hi.")
30
-
31
- # Assert the response content
32
- assert_agent_says(
33
- "End invocation event before agent call.",
34
- agent_name="before_agent_callback_agent",
35
- agent_runner=agent_runner,
36
- )
37
-
38
-
39
- @mark.parametrize(
40
- "agent_runner",
41
- [{"agent": callback_agent.agent.before_model_callback_agent}],
42
- indirect=True,
43
- )
44
- def test_before_model_call(agent_runner: TestRunner):
45
- agent_runner.run("Hi.")
46
-
47
- # Assert the response content
48
- assert_agent_says(
49
- "End invocation event before model call.",
50
- agent_name="before_model_callback_agent",
51
- agent_runner=agent_runner,
52
- )
53
-
54
-
55
- # TODO: re-enable vertex by removing below line after fixing.
56
- @mark.parametrize("llm_backend", ["GOOGLE_AI"], indirect=True)
57
- @mark.parametrize(
58
- "agent_runner",
59
- [{"agent": callback_agent.agent.after_model_callback_agent}],
60
- indirect=True,
61
- )
62
- def test_after_model_call(agent_runner: TestRunner):
63
- events = agent_runner.run("Hi.")
64
-
65
- # Assert the response content
66
- simplified_events = simplify_events(events)
67
- assert simplified_events[0][0] == "after_model_callback_agent"
68
- assert simplified_events[0][1].endswith(
69
- "Update response event after model call."
70
- )
@@ -1,67 +0,0 @@
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
- import json
16
-
17
- import pytest
18
-
19
- # Skip until fixed.
20
- pytest.skip(allow_module_level=True)
21
-
22
- from .fixture import context_variable_agent
23
- from .utils import TestRunner
24
-
25
-
26
- @pytest.mark.parametrize(
27
- "agent_runner",
28
- [{"agent": context_variable_agent.agent.state_variable_echo_agent}],
29
- indirect=True,
30
- )
31
- def test_context_variable_missing(agent_runner: TestRunner):
32
- with pytest.raises(KeyError) as e_info:
33
- agent_runner.run("Hi echo my customer id.")
34
- assert "customerId" in str(e_info.value)
35
-
36
-
37
- @pytest.mark.parametrize(
38
- "agent_runner",
39
- [{"agent": context_variable_agent.agent.state_variable_update_agent}],
40
- indirect=True,
41
- )
42
- def test_context_variable_update(agent_runner: TestRunner):
43
- _call_function_and_assert(
44
- agent_runner,
45
- "update_fc",
46
- ["RRRR", "3.141529", ["apple", "banana"], [1, 3.14, "hello"]],
47
- "successfully",
48
- )
49
-
50
-
51
- def _call_function_and_assert(
52
- agent_runner: TestRunner, function_name: str, params, expected
53
- ):
54
- param_section = (
55
- " with params"
56
- f" {params if isinstance(params, str) else json.dumps(params)}"
57
- if params is not None
58
- else ""
59
- )
60
- agent_runner.run(
61
- f"Call {function_name}{param_section} and show me the result"
62
- )
63
-
64
- model_response_event = agent_runner.get_events()[-1]
65
- assert model_response_event.author == "context_variable_update_agent"
66
- assert model_response_event.content.role == "model"
67
- assert expected in model_response_event.content.parts[0].text.strip()
@@ -1,76 +0,0 @@
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
- """Evaluate all agents in fixture folder if evaluation test files exist."""
16
-
17
- import os
18
-
19
- from google.adk.evaluation import AgentEvaluator
20
- import pytest
21
-
22
- def agent_eval_artifacts_in_fixture():
23
- """Get all agents from fixture folder."""
24
- agent_eval_artifacts = []
25
- fixture_dir = os.path.join(os.path.dirname(__file__), 'fixture')
26
- for agent_name in os.listdir(fixture_dir):
27
- agent_dir = os.path.join(fixture_dir, agent_name)
28
- if not os.path.isdir(agent_dir):
29
- continue
30
- for filename in os.listdir(agent_dir):
31
- # Evaluation test files end with test.json
32
- if not filename.endswith('test.json'):
33
- continue
34
- initial_session_file = (
35
- f'tests/integration/fixture/{agent_name}/initial.session.json'
36
- )
37
- agent_eval_artifacts.append((
38
- f'tests.integration.fixture.{agent_name}',
39
- f'tests/integration/fixture/{agent_name}/{filename}',
40
- initial_session_file
41
- if os.path.exists(initial_session_file)
42
- else None,
43
- ))
44
-
45
- # This method gets invoked twice, sorting helps ensure that both the
46
- # invocations have the same view.
47
- agent_eval_artifacts = sorted(
48
- agent_eval_artifacts, key=lambda item: f'{item[0]}|{item[1]}'
49
- )
50
- return agent_eval_artifacts
51
-
52
-
53
- @pytest.mark.parametrize(
54
- 'agent_name, evalfile, initial_session_file',
55
- agent_eval_artifacts_in_fixture(),
56
- ids=[agent_name for agent_name, _, _ in agent_eval_artifacts_in_fixture()],
57
- )
58
- def test_evaluate_agents_long_running_4_runs_per_eval_item(
59
- agent_name, evalfile, initial_session_file
60
- ):
61
- """Test agents evaluation in fixture folder.
62
-
63
- After querying the fixture folder, we have 5 eval items. For each eval item
64
- we use 4 runs.
65
-
66
- A single eval item is a session that can have multiple queries in it.
67
- """
68
- AgentEvaluator.evaluate(
69
- agent_module=agent_name,
70
- eval_dataset_file_path_or_dir=evalfile,
71
- initial_session_file=initial_session_file,
72
- # Using a slightly higher value helps us manange the variances that may
73
- # happen in each eval.
74
- # This, of course, comes at a cost of incrased test run times.
75
- num_runs=4,
76
- )
@@ -1,28 +0,0 @@
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 google.adk.evaluation import AgentEvaluator
16
-
17
-
18
- def test_eval_agent():
19
- AgentEvaluator.evaluate(
20
- agent_module="tests.integration.fixture.trip_planner_agent",
21
- eval_dataset_file_path_or_dir=(
22
- "tests/integration/fixture/trip_planner_agent/trip_inquiry.test.json"
23
- ),
24
- initial_session_file=(
25
- "tests/integration/fixture/trip_planner_agent/initial.session.json"
26
- ),
27
- num_runs=4,
28
- )
@@ -1,42 +0,0 @@
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 google.adk.evaluation import AgentEvaluator
16
-
17
-
18
- def test_simple_multi_turn_conversation():
19
- """Test a simple multi-turn conversation."""
20
- AgentEvaluator.evaluate(
21
- agent_module="tests.integration.fixture.home_automation_agent",
22
- eval_dataset_file_path_or_dir="tests/integration/fixture/home_automation_agent/test_files/simple_multi_turn_conversation.test.json",
23
- num_runs=4,
24
- )
25
-
26
-
27
- def test_dependent_tool_calls():
28
- """Test subsequent tool calls that are dependent on previous tool calls."""
29
- AgentEvaluator.evaluate(
30
- agent_module="tests.integration.fixture.home_automation_agent",
31
- eval_dataset_file_path_or_dir="tests/integration/fixture/home_automation_agent/test_files/dependent_tool_calls.test.json",
32
- num_runs=4,
33
- )
34
-
35
-
36
- def test_memorizing_past_events():
37
- """Test memorizing past events."""
38
- AgentEvaluator.evaluate(
39
- agent_module="tests.integration.fixture.home_automation_agent",
40
- eval_dataset_file_path_or_dir="tests/integration/fixture/home_automation_agent/test_files/memorizing_past_events/eval_data.test.json",
41
- num_runs=4,
42
- )
@@ -1,23 +0,0 @@
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 google.adk.evaluation import AgentEvaluator
16
-
17
-
18
- def test_eval_agent():
19
- AgentEvaluator.evaluate(
20
- agent_module="tests.integration.fixture.home_automation_agent",
21
- eval_dataset_file_path_or_dir="tests/integration/fixture/home_automation_agent/simple_test.test.json",
22
- num_runs=4,
23
- )
@@ -1,26 +0,0 @@
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 google.adk.evaluation import AgentEvaluator
16
-
17
-
18
- def test_eval_agent():
19
- """Test hotel sub agent in a multi-agent system."""
20
- AgentEvaluator.evaluate(
21
- agent_module="tests.integration.fixture.trip_planner_agent",
22
- eval_dataset_file_path_or_dir="tests/integration/fixture/trip_planner_agent/test_files/trip_inquiry_sub_agent.test.json",
23
- initial_session_file="tests/integration/fixture/trip_planner_agent/test_files/initial.session.json",
24
- agent_name="identify_agent",
25
- num_runs=4,
26
- )
@@ -1,177 +0,0 @@
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
- import pytest
16
-
17
- # Skip until fixed.
18
- pytest.skip(allow_module_level=True)
19
-
20
- from google.adk.agents import InvocationContext
21
- from google.adk.sessions import Session
22
- from google.genai import types
23
-
24
- from .fixture import context_variable_agent
25
- from .utils import TestRunner
26
-
27
- nl_planner_si = """
28
- You are an intelligent tool use agent built upon the Gemini large language model. When answering the question, try to leverage the available tools to gather the information instead of your memorized knowledge.
29
-
30
- Follow this process when answering the question: (1) first come up with a plan in natural language text format; (2) Then use tools to execute the plan and provide reasoning between tool code snippets to make a summary of current state and next step. Tool code snippets and reasoning should be interleaved with each other. (3) In the end, return one final answer.
31
-
32
- Follow this format when answering the question: (1) The planning part should be under /*PLANNING*/. (2) The tool code snippets should be under /*ACTION*/, and the reasoning parts should be under /*REASONING*/. (3) The final answer part should be under /*FINAL_ANSWER*/.
33
-
34
-
35
- Below are the requirements for the planning:
36
- The plan is made to answer the user query if following the plan. The plan is coherent and covers all aspects of information from user query, and only involves the tools that are accessible by the agent. The plan contains the decomposed steps as a numbered list where each step should use one or multiple available tools. By reading the plan, you can intuitively know which tools to trigger or what actions to take.
37
- If the initial plan cannot be successfully executed, you should learn from previous execution results and revise your plan. The revised plan should be be under /*REPLANNING*/. Then use tools to follow the new plan.
38
-
39
- Below are the requirements for the reasoning:
40
- The reasoning makes a summary of the current trajectory based on the user query and tool outputs. Based on the tool outputs and plan, the reasoning also comes up with instructions to the next steps, making the trajectory closer to the final answer.
41
-
42
-
43
-
44
- Below are the requirements for the final answer:
45
- The final answer should be precise and follow query formatting requirements. Some queries may not be answerable with the available tools and information. In those cases, inform the user why you cannot process their query and ask for more information.
46
-
47
-
48
-
49
- Below are the requirements for the tool code:
50
-
51
- **Custom Tools:** The available tools are described in the context and can be directly used.
52
- - Code must be valid self-contained Python snippets with no imports and no references to tools or Python libraries that are not in the context.
53
- - You cannot use any parameters or fields that are not explicitly defined in the APIs in the context.
54
- - Use "print" to output execution results for the next step or final answer that you need for responding to the user. Never generate ```tool_outputs yourself.
55
- - The code snippets should be readable, efficient, and directly relevant to the user query and reasoning steps.
56
- - When using the tools, you should use the library name together with the function name, e.g., vertex_search.search().
57
- - If Python libraries are not provided in the context, NEVER write your own code other than the function calls using the provided tools.
58
-
59
-
60
-
61
- VERY IMPORTANT instruction that you MUST follow in addition to the above instructions:
62
-
63
- You should ask for clarification if you need more information to answer the question.
64
- You should prefer using the information available in the context instead of repeated tool use.
65
-
66
- You should ONLY generate code snippets prefixed with "```tool_code" if you need to use the tools to answer the question.
67
-
68
- If you are asked to write code by user specifically,
69
- - you should ALWAYS use "```python" to format the code.
70
- - you should NEVER put "tool_code" to format the code.
71
- - Good example:
72
- ```python
73
- print('hello')
74
- ```
75
- - Bad example:
76
- ```tool_code
77
- print('hello')
78
- ```
79
- """
80
-
81
-
82
- @pytest.mark.parametrize(
83
- "agent_runner",
84
- [{"agent": context_variable_agent.agent.state_variable_echo_agent}],
85
- indirect=True,
86
- )
87
- def test_context_variable(agent_runner: TestRunner):
88
- session = Session(
89
- context={
90
- "customerId": "1234567890",
91
- "customerInt": 30,
92
- "customerFloat": 12.34,
93
- "customerJson": {"name": "John Doe", "age": 30, "count": 11.1},
94
- }
95
- )
96
- si = UnitFlow()._build_system_instruction(
97
- InvocationContext(
98
- invocation_id="1234567890", agent=agent_runner.agent, session=session
99
- )
100
- )
101
-
102
- assert (
103
- "Use the echo_info tool to echo 1234567890, 30, 12.34, and {'name': 'John"
104
- " Doe', 'age': 30, 'count': 11.1}. Ask for it if you need to."
105
- in si
106
- )
107
-
108
-
109
- @pytest.mark.parametrize(
110
- "agent_runner",
111
- [{
112
- "agent": (
113
- context_variable_agent.agent.state_variable_with_complicated_format_agent
114
- )
115
- }],
116
- indirect=True,
117
- )
118
- def test_context_variable_with_complicated_format(agent_runner: TestRunner):
119
- session = Session(
120
- context={"customerId": "1234567890", "customer_int": 30},
121
- artifacts={"fileName": [types.Part(text="test artifact")]},
122
- )
123
- si = _context_formatter.populate_context_and_artifact_variable_values(
124
- agent_runner.agent.instruction,
125
- session.get_state(),
126
- session.get_artifact_dict(),
127
- )
128
-
129
- assert (
130
- si
131
- == "Use the echo_info tool to echo 1234567890, 30, { "
132
- " non-identifier-float}}, test artifact, {'key1': 'value1'} and"
133
- " {{'key2': 'value2'}}. Ask for it if you need to."
134
- )
135
-
136
-
137
- @pytest.mark.parametrize(
138
- "agent_runner",
139
- [{
140
- "agent": (
141
- context_variable_agent.agent.state_variable_with_nl_planner_agent
142
- )
143
- }],
144
- indirect=True,
145
- )
146
- def test_nl_planner(agent_runner: TestRunner):
147
- session = Session(context={"customerId": "1234567890"})
148
- si = UnitFlow()._build_system_instruction(
149
- InvocationContext(
150
- invocation_id="1234567890",
151
- agent=agent_runner.agent,
152
- session=session,
153
- )
154
- )
155
-
156
- for line in nl_planner_si.splitlines():
157
- assert line in si
158
-
159
-
160
- @pytest.mark.parametrize(
161
- "agent_runner",
162
- [{
163
- "agent": (
164
- context_variable_agent.agent.state_variable_with_function_instruction_agent
165
- )
166
- }],
167
- indirect=True,
168
- )
169
- def test_function_instruction(agent_runner: TestRunner):
170
- session = Session(context={"customerId": "1234567890"})
171
- si = UnitFlow()._build_system_instruction(
172
- InvocationContext(
173
- invocation_id="1234567890", agent=agent_runner.agent, session=session
174
- )
175
- )
176
-
177
- assert "This is the plain text sub agent instruction." in si