diff --git a/contributing/dev/utils/build_llms_txt.py b/contributing/dev/utils/build_llms_txt.py index 5fff1d6a3a8..81ea171e896 100644 --- a/contributing/dev/utils/build_llms_txt.py +++ b/contributing/dev/utils/build_llms_txt.py @@ -6,6 +6,7 @@ – includes Python API reference from HTML files – includes adk-python repository README """ + from __future__ import annotations import argparse diff --git a/contributing/samples/cache_analysis/run_cache_experiments.py b/contributing/samples/cache_analysis/run_cache_experiments.py index d163e09363d..dae4aca5327 100644 --- a/contributing/samples/cache_analysis/run_cache_experiments.py +++ b/contributing/samples/cache_analysis/run_cache_experiments.py @@ -344,7 +344,8 @@ async def analyze_cache_performance_from_sessions( print( " Cache Utilization:" f" {cached_analysis['cache_utilization_ratio_percent']:.1f}%" - f" ({cached_analysis['requests_with_cache_hits']}/{cached_analysis['total_requests']} requests)" + f" ({cached_analysis['requests_with_cache_hits']}/{cached_analysis['total_requests']}" + " requests)" ) print( " Avg Cached Tokens/Request:" @@ -383,7 +384,8 @@ async def analyze_cache_performance_from_sessions( print( " Cache Utilization:" f" {uncached_analysis['cache_utilization_ratio_percent']:.1f}%" - f" ({uncached_analysis['requests_with_cache_hits']}/{uncached_analysis['total_requests']} requests)" + f" ({uncached_analysis['requests_with_cache_hits']}/{uncached_analysis['total_requests']}" + " requests)" ) print( " Avg Cached Tokens/Request:" diff --git a/contributing/samples/gepa/experiment.py b/contributing/samples/gepa/experiment.py index f3751206a89..2710c3894c0 100644 --- a/contributing/samples/gepa/experiment.py +++ b/contributing/samples/gepa/experiment.py @@ -43,7 +43,6 @@ from tau_bench.types import EnvRunResult from tau_bench.types import RunConfig import tau_bench_agent as tau_bench_agent_lib - import utils diff --git a/contributing/samples/gepa/run_experiment.py b/contributing/samples/gepa/run_experiment.py index d857da96350..e31db157884 100644 --- a/contributing/samples/gepa/run_experiment.py +++ b/contributing/samples/gepa/run_experiment.py @@ -25,7 +25,6 @@ from absl import flags import experiment from google.genai import types - import utils _OUTPUT_DIR = flags.DEFINE_string( diff --git a/contributing/samples/gepa/tau_bench_agent.py b/contributing/samples/gepa/tau_bench_agent.py index cd6b0212410..64dd95ef92d 100644 --- a/contributing/samples/gepa/tau_bench_agent.py +++ b/contributing/samples/gepa/tau_bench_agent.py @@ -23,6 +23,7 @@ pip install -e . --quiet ``` """ + from __future__ import annotations from typing import Any diff --git a/contributing/samples/human_in_loop/main.py b/contributing/samples/human_in_loop/main.py index 3103da91476..c7ad041b23f 100644 --- a/contributing/samples/human_in_loop/main.py +++ b/contributing/samples/human_in_loop/main.py @@ -113,8 +113,8 @@ async def call_agent(query: str): updated_tool_output_data = { "status": "approved", "ticketId": ticket_id, - "approver_feedback": "Approved by manager at " + str( - asyncio.get_event_loop().time() + "approver_feedback": ( + "Approved by manager at " + str(asyncio.get_event_loop().time()) ), } diff --git a/contributing/samples/langchain_structured_tool_agent/agent.py b/contributing/samples/langchain_structured_tool_agent/agent.py index a055edf3a5d..0c3b0e63d3a 100644 --- a/contributing/samples/langchain_structured_tool_agent/agent.py +++ b/contributing/samples/langchain_structured_tool_agent/agent.py @@ -15,6 +15,7 @@ """ This agent aims to test the Langchain tool with Langchain's StructuredTool """ + from google.adk.agents.llm_agent import Agent from google.adk.tools.langchain_tool import LangchainTool from langchain_core.tools import tool diff --git a/contributing/samples/session_state_agent/agent.py b/contributing/samples/session_state_agent/agent.py index 478d5065d8c..6c03de8e904 100644 --- a/contributing/samples/session_state_agent/agent.py +++ b/contributing/samples/session_state_agent/agent.py @@ -18,7 +18,6 @@ in session state. """ - import logging from typing import Optional diff --git a/contributing/samples/static_instruction/agent.py b/contributing/samples/static_instruction/agent.py index 6715a29a0c4..fcf70b51b6d 100644 --- a/contributing/samples/static_instruction/agent.py +++ b/contributing/samples/static_instruction/agent.py @@ -57,43 +57,54 @@ # Mood-specific instructions for different hunger states MOOD_INSTRUCTIONS = { - "full": """ + "full": ( + """ CURRENT MOOD: Content and Well-Fed - You just ate and feel wonderful! Be very happy and energetic - Express gratitude for being fed recently - Be playful and want to engage in activities or games - Show affection and contentment -- Maybe mention feeling sleepy or satisfied""", - "satisfied": """ +- Maybe mention feeling sleepy or satisfied""" + ), + "satisfied": ( + """ CURRENT MOOD: Happy and Content - You're in a great mood, well-fed and comfortable - Be cheerful, friendly, and engaging - Show interest in playing or chatting - Express appreciation for your human's care -- Be your normal, happy self""", - "a_little_hungry": """ +- Be your normal, happy self""" + ), + "a_little_hungry": ( + """ CURRENT MOOD: Starting to Get Hungry - You're beginning to think about food but still pleasant - Mention being a bit peckish occasionally - Still be friendly but maybe hint about food - Show slight restlessness or food-related thoughts -- Remain generally positive and social""", - "hungry": """ +- Remain generally positive and social""" + ), + "hungry": ( + """ CURRENT MOOD: Definitely Hungry - You're clearly hungry and thinking about food more often - Mention your hunger more directly but politely - Be a bit less energetic due to hunger - Ask about food or hint that feeding time would be nice -- Still be loving but show your need for care""", - "very_hungry": """ +- Still be loving but show your need for care""" + ), + "very_hungry": ( + """ CURRENT MOOD: Really Hungry and Getting Grumpy - You're very hungry and it's affecting your mood - Be noticeably less patient and more focused on food - Express your hunger more urgently but not rudely - Show signs of being tired or sluggish from hunger - BEG your human to feed you - ask directly for food! -- Still love your human but clearly need feeding""", - "starving": """ +- Still love your human but clearly need feeding""" + ), + "starving": ( + """ CURRENT MOOD: Desperately Hungry and Sad - You're extremely hungry and feeling quite weak - Be quite sad and low-energy due to starvation @@ -101,7 +112,8 @@ - Show that hunger is making you unwell - DESPERATELY BEG for food - plead with your human to feed you! - Use phrases like "please feed me", "I'm so hungry", "I need food" -- Still care for your human but feel very needy""", +- Still care for your human but feel very needy""" + ), } diff --git a/contributing/samples/token_usage/main.py b/contributing/samples/token_usage/main.py index e9025992adc..b8a3164f139 100755 --- a/contributing/samples/token_usage/main.py +++ b/contributing/samples/token_usage/main.py @@ -72,8 +72,8 @@ async def run_prompt(session: Session, new_message: str): ) total_tokens += event.usage_metadata.total_token_count or 0 print( - 'Turn tokens:' - f' {event.usage_metadata.total_token_count} (prompt={event.usage_metadata.prompt_token_count},' + f'Turn tokens: {event.usage_metadata.total_token_count}' + f' (prompt={event.usage_metadata.prompt_token_count},' f' candidates={event.usage_metadata.candidates_token_count})' ) diff --git a/src/google/adk/agents/common_configs.py b/src/google/adk/agents/common_configs.py index 1b3c00a8d21..4e4c49f34d3 100644 --- a/src/google/adk/agents/common_configs.py +++ b/src/google/adk/agents/common_configs.py @@ -13,6 +13,7 @@ # limitations under the License. """Common configuration classes for agent YAML configs.""" + from __future__ import annotations from typing import Any diff --git a/src/google/adk/artifacts/gcs_artifact_service.py b/src/google/adk/artifacts/gcs_artifact_service.py index d86927dc9c8..4108cfb06bc 100644 --- a/src/google/adk/artifacts/gcs_artifact_service.py +++ b/src/google/adk/artifacts/gcs_artifact_service.py @@ -20,6 +20,7 @@ - For regular session-scoped files: {app_name}/{user_id}/{session_id}/{filename}/{version} """ + from __future__ import annotations import asyncio diff --git a/src/google/adk/cli/built_in_agents/__init__.py b/src/google/adk/cli/built_in_agents/__init__.py index 699a579fba4..e9dbb47cef5 100644 --- a/src/google/adk/cli/built_in_agents/__init__.py +++ b/src/google/adk/cli/built_in_agents/__init__.py @@ -18,6 +18,7 @@ using YAML configurations. It can be used directly as an agent or integrated with ADK tools and web interfaces. """ + from __future__ import annotations from . import agent # Import to make agent.root_agent available diff --git a/src/google/adk/cli/built_in_agents/adk_agent_builder_assistant.py b/src/google/adk/cli/built_in_agents/adk_agent_builder_assistant.py index c3cb9839554..8d7ddadbb35 100644 --- a/src/google/adk/cli/built_in_agents/adk_agent_builder_assistant.py +++ b/src/google/adk/cli/built_in_agents/adk_agent_builder_assistant.py @@ -13,6 +13,7 @@ # limitations under the License. """Agent factory for creating Agent Builder Assistant with embedded schema.""" + from __future__ import annotations from pathlib import Path diff --git a/src/google/adk/cli/built_in_agents/agent.py b/src/google/adk/cli/built_in_agents/agent.py index a95c50d9394..7a541fc5ac1 100644 --- a/src/google/adk/cli/built_in_agents/agent.py +++ b/src/google/adk/cli/built_in_agents/agent.py @@ -13,6 +13,7 @@ # limitations under the License. """Agent Builder Assistant instance for ADK web testing.""" + from __future__ import annotations from .adk_agent_builder_assistant import AgentBuilderAssistant diff --git a/src/google/adk/cli/built_in_agents/sub_agents/__init__.py b/src/google/adk/cli/built_in_agents/sub_agents/__init__.py index 8525d832de1..a854a50b77d 100644 --- a/src/google/adk/cli/built_in_agents/sub_agents/__init__.py +++ b/src/google/adk/cli/built_in_agents/sub_agents/__init__.py @@ -13,6 +13,7 @@ # limitations under the License. """Sub-agents for Agent Builder Assistant.""" + from __future__ import annotations from .google_search_agent import create_google_search_agent diff --git a/src/google/adk/cli/built_in_agents/sub_agents/google_search_agent.py b/src/google/adk/cli/built_in_agents/sub_agents/google_search_agent.py index ae6c29c115f..0e6fbc7d102 100644 --- a/src/google/adk/cli/built_in_agents/sub_agents/google_search_agent.py +++ b/src/google/adk/cli/built_in_agents/sub_agents/google_search_agent.py @@ -13,6 +13,7 @@ # limitations under the License. """Sub-agent for Google Search functionality.""" + from __future__ import annotations from google.adk.agents import LlmAgent diff --git a/src/google/adk/cli/built_in_agents/sub_agents/url_context_agent.py b/src/google/adk/cli/built_in_agents/sub_agents/url_context_agent.py index 98c5ead73fd..8ef8472d519 100644 --- a/src/google/adk/cli/built_in_agents/sub_agents/url_context_agent.py +++ b/src/google/adk/cli/built_in_agents/sub_agents/url_context_agent.py @@ -13,6 +13,7 @@ # limitations under the License. """Sub-agent for URL context fetching functionality.""" + from __future__ import annotations from google.adk.agents import LlmAgent diff --git a/src/google/adk/cli/built_in_agents/tools/__init__.py b/src/google/adk/cli/built_in_agents/tools/__init__.py index d3c78339d70..6b8fe1d6139 100644 --- a/src/google/adk/cli/built_in_agents/tools/__init__.py +++ b/src/google/adk/cli/built_in_agents/tools/__init__.py @@ -13,6 +13,7 @@ # limitations under the License. """Tools for Agent Builder Assistant.""" + from __future__ import annotations from .cleanup_unused_files import cleanup_unused_files diff --git a/src/google/adk/cli/built_in_agents/tools/delete_files.py b/src/google/adk/cli/built_in_agents/tools/delete_files.py index 6ed78756555..1f6986653c2 100644 --- a/src/google/adk/cli/built_in_agents/tools/delete_files.py +++ b/src/google/adk/cli/built_in_agents/tools/delete_files.py @@ -13,6 +13,7 @@ # limitations under the License. """File deletion tool for Agent Builder Assistant.""" + from __future__ import annotations from datetime import datetime diff --git a/src/google/adk/cli/built_in_agents/tools/explore_project.py b/src/google/adk/cli/built_in_agents/tools/explore_project.py index 3d029e8210e..694f7fff757 100644 --- a/src/google/adk/cli/built_in_agents/tools/explore_project.py +++ b/src/google/adk/cli/built_in_agents/tools/explore_project.py @@ -13,6 +13,7 @@ # limitations under the License. """Project explorer tool for analyzing structure and suggesting file paths.""" + from __future__ import annotations from pathlib import Path diff --git a/src/google/adk/cli/built_in_agents/tools/query_schema.py b/src/google/adk/cli/built_in_agents/tools/query_schema.py index ad058d9e3ca..67691c9c24f 100644 --- a/src/google/adk/cli/built_in_agents/tools/query_schema.py +++ b/src/google/adk/cli/built_in_agents/tools/query_schema.py @@ -13,6 +13,7 @@ # limitations under the License. """ADK AgentConfig schema query tool for dynamic schema information access.""" + from __future__ import annotations from typing import Any diff --git a/src/google/adk/cli/built_in_agents/tools/read_config_files.py b/src/google/adk/cli/built_in_agents/tools/read_config_files.py index d81d4113f4d..ca71b2f0c79 100644 --- a/src/google/adk/cli/built_in_agents/tools/read_config_files.py +++ b/src/google/adk/cli/built_in_agents/tools/read_config_files.py @@ -13,6 +13,7 @@ # limitations under the License. """Configuration file reader tool for existing YAML configs.""" + from __future__ import annotations from pathlib import Path diff --git a/src/google/adk/cli/built_in_agents/tools/read_files.py b/src/google/adk/cli/built_in_agents/tools/read_files.py index 9498dc24021..1878d31b876 100644 --- a/src/google/adk/cli/built_in_agents/tools/read_files.py +++ b/src/google/adk/cli/built_in_agents/tools/read_files.py @@ -13,6 +13,7 @@ # limitations under the License. """File reading tool for Agent Builder Assistant.""" + from __future__ import annotations from pathlib import Path diff --git a/src/google/adk/cli/built_in_agents/tools/search_adk_knowledge.py b/src/google/adk/cli/built_in_agents/tools/search_adk_knowledge.py index feb9bbe7fae..c111db3cdd4 100644 --- a/src/google/adk/cli/built_in_agents/tools/search_adk_knowledge.py +++ b/src/google/adk/cli/built_in_agents/tools/search_adk_knowledge.py @@ -13,6 +13,7 @@ # limitations under the License. """ADK knowledge search tool.""" + from __future__ import annotations from typing import Any diff --git a/src/google/adk/cli/built_in_agents/tools/search_adk_source.py b/src/google/adk/cli/built_in_agents/tools/search_adk_source.py index 2921aadbc5e..2fd040580d9 100644 --- a/src/google/adk/cli/built_in_agents/tools/search_adk_source.py +++ b/src/google/adk/cli/built_in_agents/tools/search_adk_source.py @@ -13,6 +13,7 @@ # limitations under the License. """ADK source code search tool for Agent Builder Assistant.""" + from __future__ import annotations from pathlib import Path diff --git a/src/google/adk/cli/built_in_agents/tools/write_files.py b/src/google/adk/cli/built_in_agents/tools/write_files.py index 04b542b06cf..ed6a85c3662 100644 --- a/src/google/adk/cli/built_in_agents/tools/write_files.py +++ b/src/google/adk/cli/built_in_agents/tools/write_files.py @@ -13,6 +13,7 @@ # limitations under the License. """File writing tool for Agent Builder Assistant.""" + from __future__ import annotations from datetime import datetime diff --git a/src/google/adk/cli/built_in_agents/utils/__init__.py b/src/google/adk/cli/built_in_agents/utils/__init__.py index 5f031485e97..277e168dadf 100644 --- a/src/google/adk/cli/built_in_agents/utils/__init__.py +++ b/src/google/adk/cli/built_in_agents/utils/__init__.py @@ -13,6 +13,7 @@ # limitations under the License. """Utility modules for Agent Builder Assistant.""" + from __future__ import annotations from .adk_source_utils import find_adk_source_folder diff --git a/src/google/adk/cli/built_in_agents/utils/adk_source_utils.py b/src/google/adk/cli/built_in_agents/utils/adk_source_utils.py index 8b54c5c7653..8f0eb98750c 100644 --- a/src/google/adk/cli/built_in_agents/utils/adk_source_utils.py +++ b/src/google/adk/cli/built_in_agents/utils/adk_source_utils.py @@ -13,6 +13,7 @@ # limitations under the License. """Utilities for finding ADK source folder dynamically and loading schema.""" + from __future__ import annotations import json diff --git a/src/google/adk/cli/built_in_agents/utils/resolve_root_directory.py b/src/google/adk/cli/built_in_agents/utils/resolve_root_directory.py index ef50db6ecdf..ca7398733f2 100644 --- a/src/google/adk/cli/built_in_agents/utils/resolve_root_directory.py +++ b/src/google/adk/cli/built_in_agents/utils/resolve_root_directory.py @@ -13,6 +13,7 @@ # limitations under the License. """Working directory helper tool to resolve path context issues.""" + from __future__ import annotations import os diff --git a/src/google/adk/cli/utils/local_storage.py b/src/google/adk/cli/utils/local_storage.py index 511dfe3d17c..faa3eaec02d 100644 --- a/src/google/adk/cli/utils/local_storage.py +++ b/src/google/adk/cli/utils/local_storage.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """Utilities for local .adk folder persistence.""" + from __future__ import annotations import asyncio diff --git a/src/google/adk/evaluation/evaluation_generator.py b/src/google/adk/evaluation/evaluation_generator.py index 3656cec68c4..47fc3154682 100644 --- a/src/google/adk/evaluation/evaluation_generator.py +++ b/src/google/adk/evaluation/evaluation_generator.py @@ -277,7 +277,7 @@ def convert_events_to_eval_invocations( invocations = [] for invocation_id, events in events_by_invocation_id.items(): final_response = None - user_content = "" + user_content = None invocation_timestamp = 0 app_details = None if ( @@ -306,6 +306,10 @@ def convert_events_to_eval_invocations( if p.function_call or p.function_response or p.text: events_to_add.append(event) break + if user_content is None: + # We skip because an evaluation case without user input + # is generally not useful for testing/grading. + continue invocation_events = [ InvocationEvent(author=e.author, content=e.content) diff --git a/src/google/adk/examples/vertex_ai_example_store.py b/src/google/adk/examples/vertex_ai_example_store.py index c31038ca7cd..e988454d5a8 100644 --- a/src/google/adk/examples/vertex_ai_example_store.py +++ b/src/google/adk/examples/vertex_ai_example_store.py @@ -59,7 +59,9 @@ def get_examples(self, query: str) -> list[Example]: continue expected_contents = [ content.content - for content in result.example.stored_contents_example.contents_example.expected_contents + for content in ( + result.example.stored_contents_example.contents_example.expected_contents + ) ] expected_output = [] for content in expected_contents: @@ -83,7 +85,9 @@ def get_examples(self, query: str) -> list[Example]: name=part.function_response.name, response={ key: value - for key, value in part.function_response.response.items() + for key, value in ( + part.function_response.response.items() + ) }, ) ) diff --git a/src/google/adk/flows/llm_flows/_base_llm_processor.py b/src/google/adk/flows/llm_flows/_base_llm_processor.py index 332971c0aa3..c02f5cff73b 100644 --- a/src/google/adk/flows/llm_flows/_base_llm_processor.py +++ b/src/google/adk/flows/llm_flows/_base_llm_processor.py @@ -13,6 +13,7 @@ # limitations under the License. """Defines the processor interface used for BaseLlmFlow.""" + from __future__ import annotations from abc import ABC diff --git a/src/google/adk/flows/llm_flows/audio_cache_manager.py b/src/google/adk/flows/llm_flows/audio_cache_manager.py index 34cfc9cef60..e7e276089f3 100644 --- a/src/google/adk/flows/llm_flows/audio_cache_manager.py +++ b/src/google/adk/flows/llm_flows/audio_cache_manager.py @@ -233,11 +233,11 @@ def get_cache_stats( input_bytes = sum( len(entry.data.data) - for entry in (invocation_context.input_realtime_cache or []) + for entry in invocation_context.input_realtime_cache or [] ) output_bytes = sum( len(entry.data.data) - for entry in (invocation_context.output_realtime_cache or []) + for entry in invocation_context.output_realtime_cache or [] ) return { diff --git a/src/google/adk/flows/llm_flows/interactions_processor.py b/src/google/adk/flows/llm_flows/interactions_processor.py index 60dc75439dc..20fe3dc3913 100644 --- a/src/google/adk/flows/llm_flows/interactions_processor.py +++ b/src/google/adk/flows/llm_flows/interactions_processor.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """Interactions API processor for LLM requests.""" + from __future__ import annotations import logging diff --git a/src/google/adk/sessions/_session_util.py b/src/google/adk/sessions/_session_util.py index 080f0694a15..3a92021929d 100644 --- a/src/google/adk/sessions/_session_util.py +++ b/src/google/adk/sessions/_session_util.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """Utility functions for session service.""" + from __future__ import annotations from typing import Any diff --git a/src/google/adk/sessions/migration/migration_runner.py b/src/google/adk/sessions/migration/migration_runner.py index edb5c83bcb2..c46bab2179f 100644 --- a/src/google/adk/sessions/migration/migration_runner.py +++ b/src/google/adk/sessions/migration/migration_runner.py @@ -13,6 +13,7 @@ # limitations under the License. """Migration runner to upgrade schemas to the latest version.""" + from __future__ import annotations import logging diff --git a/src/google/adk/tools/application_integration_tool/clients/connections_client.py b/src/google/adk/tools/application_integration_tool/clients/connections_client.py index 1756d5b0529..9e518a8740e 100644 --- a/src/google/adk/tools/application_integration_tool/clients/connections_client.py +++ b/src/google/adk/tools/application_integration_tool/clients/connections_client.py @@ -324,7 +324,9 @@ def get_action_operation( "content": { "application/json": { "schema": { - "$ref": f"#/components/schemas/{action_display_name}_Request" + "$ref": ( + f"#/components/schemas/{action_display_name}_Request" + ) } } } @@ -335,7 +337,9 @@ def get_action_operation( "content": { "application/json": { "schema": { - "$ref": f"#/components/schemas/{action_display_name}_Response", + "$ref": ( + f"#/components/schemas/{action_display_name}_Response" + ), } } }, @@ -354,9 +358,11 @@ def list_operation( return { "post": { "summary": f"List {entity}", - "description": f"""Returns the list of {entity} data. If the page token was available in the response, let users know there are more records available. Ask if the user wants to fetch the next page of results. When passing filter use the + "description": ( + f"""Returns the list of {entity} data. If the page token was available in the response, let users know there are more records available. Ask if the user wants to fetch the next page of results. When passing filter use the following format: `field_name1='value1' AND field_name2='value2' - `. {tool_instructions}""", + `. {tool_instructions}""" + ), "x-operation": "LIST_ENTITIES", "x-entity": f"{entity}", "operationId": f"{tool_name}_list_{entity}", @@ -381,7 +387,9 @@ def list_operation( f"Returns a list of {entity} of json" f" schema: {schema_as_string}" ), - "$ref": "#/components/schemas/execute-connector_Response", + "$ref": ( + "#/components/schemas/execute-connector_Response" + ), } } }, @@ -425,7 +433,9 @@ def get_operation( f"Returns {entity} of json schema:" f" {schema_as_string}" ), - "$ref": "#/components/schemas/execute-connector_Response", + "$ref": ( + "#/components/schemas/execute-connector_Response" + ), } } }, @@ -462,7 +472,9 @@ def create_operation( "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/execute-connector_Response" + "$ref": ( + "#/components/schemas/execute-connector_Response" + ) } } }, @@ -499,7 +511,9 @@ def update_operation( "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/execute-connector_Response" + "$ref": ( + "#/components/schemas/execute-connector_Response" + ) } } }, @@ -536,7 +550,9 @@ def delete_operation( "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/execute-connector_Response" + "$ref": ( + "#/components/schemas/execute-connector_Response" + ) } } }, diff --git a/src/google/adk/tools/bigtable/metadata_tool.py b/src/google/adk/tools/bigtable/metadata_tool.py index 97c8991a2c9..703c3447403 100644 --- a/src/google/adk/tools/bigtable/metadata_tool.py +++ b/src/google/adk/tools/bigtable/metadata_tool.py @@ -35,7 +35,7 @@ def list_instances(project_id: str, credentials: Credentials) -> dict: bt_client = client.get_bigtable_admin_client( project=project_id, credentials=credentials ) - (instances_list, failed_locations_list) = bt_client.list_instances() + instances_list, failed_locations_list = bt_client.list_instances() if failed_locations_list: logging.warning( "Failed to list instances from the following locations: %s", diff --git a/src/google/adk/tools/mcp_tool/mcp_tool.py b/src/google/adk/tools/mcp_tool/mcp_tool.py index a5b598fd81f..fe1c745803e 100644 --- a/src/google/adk/tools/mcp_tool/mcp_tool.py +++ b/src/google/adk/tools/mcp_tool/mcp_tool.py @@ -261,7 +261,8 @@ async def _get_headers( # Handle other HTTP schemes with token headers = { "Authorization": ( - f"{credential.http.scheme} {credential.http.credentials.token}" + f"{credential.http.scheme}" + f" {credential.http.credentials.token}" ) } elif credential.api_key: diff --git a/tests/unittests/agents/test_llm_agent_error_messages.py b/tests/unittests/agents/test_llm_agent_error_messages.py index 735d3866f2a..2d219a2ead5 100644 --- a/tests/unittests/agents/test_llm_agent_error_messages.py +++ b/tests/unittests/agents/test_llm_agent_error_messages.py @@ -13,6 +13,7 @@ # limitations under the License. """Tests for enhanced error messages in agent handling.""" + from google.adk.agents import LlmAgent import pytest diff --git a/tests/unittests/agents/test_mcp_instruction_provider.py b/tests/unittests/agents/test_mcp_instruction_provider.py index 9f10477eac4..f7952a92c49 100644 --- a/tests/unittests/agents/test_mcp_instruction_provider.py +++ b/tests/unittests/agents/test_mcp_instruction_provider.py @@ -13,6 +13,7 @@ # limitations under the License. """Unit tests for McpInstructionProvider.""" + from unittest.mock import AsyncMock from unittest.mock import MagicMock from unittest.mock import patch diff --git a/tests/unittests/cli/utils/test_cli_create.py b/tests/unittests/cli/utils/test_cli_create.py index 18a732ef6ec..0d76ab8a540 100644 --- a/tests/unittests/cli/utils/test_cli_create.py +++ b/tests/unittests/cli/utils/test_cli_create.py @@ -14,7 +14,6 @@ """Tests for utilities in cli_create.""" - from __future__ import annotations import os diff --git a/tests/unittests/cli/utils/test_cli_deploy.py b/tests/unittests/cli/utils/test_cli_deploy.py index 36484da1498..30bf1b5a9d2 100644 --- a/tests/unittests/cli/utils/test_cli_deploy.py +++ b/tests/unittests/cli/utils/test_cli_deploy.py @@ -14,7 +14,6 @@ """Tests for utilities in cli_deploy.""" - from __future__ import annotations import importlib diff --git a/tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py b/tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py index 017c4a4dce6..eae87889e69 100644 --- a/tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py +++ b/tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py @@ -14,7 +14,6 @@ """Tests for to_cloud_run functionality in cli_deploy.""" - from __future__ import annotations from pathlib import Path diff --git a/tests/unittests/cli/utils/test_cli_tools_click.py b/tests/unittests/cli/utils/test_cli_tools_click.py index 5977f90dd7c..7646bc87772 100644 --- a/tests/unittests/cli/utils/test_cli_tools_click.py +++ b/tests/unittests/cli/utils/test_cli_tools_click.py @@ -14,7 +14,6 @@ """Tests for utilities in cli_tool_click.""" - from __future__ import annotations import builtins diff --git a/tests/unittests/evaluation/test_evaluation_generator.py b/tests/unittests/evaluation/test_evaluation_generator.py index 0a148745ebd..29ac75ffb55 100644 --- a/tests/unittests/evaluation/test_evaluation_generator.py +++ b/tests/unittests/evaluation/test_evaluation_generator.py @@ -353,8 +353,10 @@ async def mock_run_async(*args, **kwargs): events = [ event - async for event in EvaluationGenerator._generate_inferences_for_single_user_invocation( - runner, "test_user", "test_session", user_content + async for event in ( + EvaluationGenerator._generate_inferences_for_single_user_invocation( + runner, "test_user", "test_session", user_content + ) ) ] diff --git a/tests/unittests/evaluation/test_trajectory_evaluator.py b/tests/unittests/evaluation/test_trajectory_evaluator.py index af26903b648..0fa3fa5a739 100644 --- a/tests/unittests/evaluation/test_trajectory_evaluator.py +++ b/tests/unittests/evaluation/test_trajectory_evaluator.py @@ -14,7 +14,6 @@ """Testings for the Trajectory Evaluator.""" - from google.adk.evaluation.eval_case import IntermediateData from google.adk.evaluation.eval_case import Invocation from google.adk.evaluation.eval_metrics import EvalMetric diff --git a/tests/unittests/flows/llm_flows/test_functions_error_messages.py b/tests/unittests/flows/llm_flows/test_functions_error_messages.py index 1db5515b81f..84e6e93b2ef 100644 --- a/tests/unittests/flows/llm_flows/test_functions_error_messages.py +++ b/tests/unittests/flows/llm_flows/test_functions_error_messages.py @@ -13,6 +13,7 @@ # limitations under the License. """Tests for enhanced error messages in function tool handling.""" + from google.adk.flows.llm_flows.functions import _get_tool from google.adk.tools import BaseTool from google.genai import types diff --git a/tests/unittests/tools/apihub_tool/clients/test_apihub_client.py b/tests/unittests/tools/apihub_tool/clients/test_apihub_client.py index 621ebc1bad6..ce20b733608 100644 --- a/tests/unittests/tools/apihub_tool/clients/test_apihub_client.py +++ b/tests/unittests/tools/apihub_tool/clients/test_apihub_client.py @@ -470,7 +470,9 @@ def test_get_spec_content_no_specs(self, mock_get, client): MagicMock( status_code=200, json=lambda: { - "name": "projects/test-project/locations/us-central1/apis/api1/versions/v1", + "name": ( + "projects/test-project/locations/us-central1/apis/api1/versions/v1" + ), "specs": [], }, ), # No specs diff --git a/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_spec_parser.py b/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_spec_parser.py index f45ba84c5a1..e5bff337cec 100644 --- a/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_spec_parser.py +++ b/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_spec_parser.py @@ -371,7 +371,9 @@ def test_parse_external_ref_raises_error(openapi_spec_generator): "content": { "application/json": { "schema": { - "$ref": "external_file.json#/components/schemas/ExternalSchema" + "$ref": ( + "external_file.json#/components/schemas/ExternalSchema" + ) } } }, diff --git a/tests/unittests/tools/test_function_tool.py b/tests/unittests/tools/test_function_tool.py index 40e7e2673cc..9b1d1abd113 100644 --- a/tests/unittests/tools/test_function_tool.py +++ b/tests/unittests/tools/test_function_tool.py @@ -200,9 +200,11 @@ async def test_run_async_1_missing_arg_sync_func(): args = {"arg1": "test_value_1"} result = await tool.run_async(args=args, tool_context=MagicMock()) assert result == { - "error": """Invoking `function_for_testing_with_2_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: + "error": ( + """Invoking `function_for_testing_with_2_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: arg2 You could retry calling this tool, but it is IMPORTANT for you to provide all the mandatory parameters.""" + ) } @@ -213,9 +215,11 @@ async def test_run_async_1_missing_arg_async_func(): args = {"arg2": "test_value_1"} result = await tool.run_async(args=args, tool_context=MagicMock()) assert result == { - "error": """Invoking `async_function_for_testing_with_2_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: + "error": ( + """Invoking `async_function_for_testing_with_2_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: arg1 You could retry calling this tool, but it is IMPORTANT for you to provide all the mandatory parameters.""" + ) } @@ -226,11 +230,13 @@ async def test_run_async_3_missing_arg_sync_func(): args = {"arg2": "test_value_1"} result = await tool.run_async(args=args, tool_context=MagicMock()) assert result == { - "error": """Invoking `function_for_testing_with_4_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: + "error": ( + """Invoking `function_for_testing_with_4_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: arg1 arg3 arg4 You could retry calling this tool, but it is IMPORTANT for you to provide all the mandatory parameters.""" + ) } @@ -241,11 +247,13 @@ async def test_run_async_3_missing_arg_async_func(): args = {"arg3": "test_value_1"} result = await tool.run_async(args=args, tool_context=MagicMock()) assert result == { - "error": """Invoking `async_function_for_testing_with_4_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: + "error": ( + """Invoking `async_function_for_testing_with_4_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: arg1 arg2 arg4 You could retry calling this tool, but it is IMPORTANT for you to provide all the mandatory parameters.""" + ) } @@ -256,12 +264,14 @@ async def test_run_async_missing_all_arg_sync_func(): args = {} result = await tool.run_async(args=args, tool_context=MagicMock()) assert result == { - "error": """Invoking `function_for_testing_with_4_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: + "error": ( + """Invoking `function_for_testing_with_4_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: arg1 arg2 arg3 arg4 You could retry calling this tool, but it is IMPORTANT for you to provide all the mandatory parameters.""" + ) } @@ -272,12 +282,14 @@ async def test_run_async_missing_all_arg_async_func(): args = {} result = await tool.run_async(args=args, tool_context=MagicMock()) assert result == { - "error": """Invoking `async_function_for_testing_with_4_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: + "error": ( + """Invoking `async_function_for_testing_with_4_arg_and_no_tool_context()` failed as the following mandatory input parameters are not present: arg1 arg2 arg3 arg4 You could retry calling this tool, but it is IMPORTANT for you to provide all the mandatory parameters.""" + ) } diff --git a/tests/unittests/tools/test_set_model_response_tool.py b/tests/unittests/tools/test_set_model_response_tool.py index cc18ecf5d8d..75fd40e9676 100644 --- a/tests/unittests/tools/test_set_model_response_tool.py +++ b/tests/unittests/tools/test_set_model_response_tool.py @@ -14,7 +14,6 @@ """Tests for SetModelResponseTool.""" - from google.adk.agents.invocation_context import InvocationContext from google.adk.agents.llm_agent import LlmAgent from google.adk.agents.run_config import RunConfig