Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/adk-unit-guide/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ Use the following structure and instructions to create the guide for the code un

- Mention any limitations of the code unit, if known.

```
```
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ repos:
rev: v2.24.0
hooks:
- id: pyproject-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.17
hooks:
- id: ruff
args: [--fix]
files: ^src/
- repo: https://github.com/PyCQA/isort
rev: 8.0.1
hooks:
Expand Down
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ optional-dependencies.dev = [
"pyink==25.12",
"pylint>=2.6",
"pyproject-fmt==2.24",
"ruff==0.15.17",
"tox>=4.23.2",
"tox-uv>=1.33.2",
]
Expand Down Expand Up @@ -260,6 +261,25 @@ module.include = [ "py.typed" ]
sdist.include = [ "src/**/*", "README.md", "pyproject.toml", "LICENSE" ]
sdist.exclude = [ "src/**/*.sh", "src/**/README.md" ]

[tool.ruff]
extend-exclude = [
"src/google/adk/cli/browser/",
# These hardcode googleapis.com endpoints and trip the check-file-contents
# mTLS policy check the moment they change. Excluded so unused-import
# cleanup does not pull them into a PR; clean them up when the mTLS policy
# is addressed.
"src/google/adk/integrations/bigquery/bigquery_credentials.py",
"src/google/adk/integrations/bigquery/data_insights_tool.py",
"src/google/adk/plugins/bigquery_agent_analytics_plugin.py",
"src/google/adk/tools/data_agent/data_agent_tool.py",
"src/google/adk/v1/",
"v1_tests/",
]
lint.select = [ "F401" ]
# __init__.py files re-export symbols for the public API; unused imports
# there are intentional, not dead code.
lint.per-file-ignores."**/__init__.py" = [ "F401" ]

[tool.isort]
profile = "google"
line_length = 200
Expand Down
11 changes: 10 additions & 1 deletion scripts/run_precommit_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ class HookSpec:
# from its .pre-commit-hooks.yaml. The `local` hooks (addlicense,
# check-new-py-prefix) are handled by _LOCAL_HOOKS below instead.
_HOOK_SPECS: dict[str, HookSpec] = {
'ruff': HookSpec(
['ruff', 'check', '--force-exclude'],
['ruff', 'check', '--fix', '--force-exclude'],
_PY,
),
'isort': HookSpec(['isort', '--check-only', '--diff'], ['isort'], _PY),
'pyink': HookSpec(['pyink', '--check', '--diff'], ['pyink'], _PY),
'pyproject-fmt': HookSpec(
Expand Down Expand Up @@ -317,7 +322,11 @@ def run_standard_hook(
if spec.is_fixer and not fix:
return _run_fixer_in_check_mode(tool, files)
command = spec.fix_cmd if (fix and spec.fix_cmd) else spec.check_cmd
return _run(command + hook.args, files)
# Drop `--fix` from the config args: check mode must not modify files, and
# fix mode already gets `--fix` from the spec's fix_cmd (passing it twice is
# an error, e.g. ruff rejects a repeated `--fix`).
args = [a for a in hook.args if a != '--fix']
return _run(command + args, files)


# --- local hooks (no upstream tool; bespoke handling) -----------------------
Expand Down
6 changes: 0 additions & 6 deletions src/google/adk/a2a/converters/from_adk_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
from typing import Dict
from typing import List
from typing import Optional
from typing import Tuple
from typing import Union
import uuid

from a2a.server.events import Event as A2AEvent
from a2a.types import Artifact
from a2a.types import DataPart
from a2a.types import Message
from a2a.types import Part as A2APart
from a2a.types import Role
Expand All @@ -39,11 +37,7 @@
from a2a.types import TextPart

from ...events.event import Event
from ...flows.llm_flows.functions import REQUEST_EUC_FUNCTION_CALL_NAME
from ..experimental import a2a_experimental
from .part_converter import A2A_DATA_PART_METADATA_IS_LONG_RUNNING_KEY
from .part_converter import A2A_DATA_PART_METADATA_TYPE_FUNCTION_CALL
from .part_converter import A2A_DATA_PART_METADATA_TYPE_KEY
from .part_converter import convert_genai_part_to_a2a_part
from .part_converter import GenAIPartToA2APartConverter
from .utils import _get_adk_metadata_key
Expand Down
1 change: 0 additions & 1 deletion src/google/adk/a2a/converters/part_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import base64
from collections.abc import Callable
import json
import logging
from typing import List
from typing import Optional
Expand Down
3 changes: 0 additions & 3 deletions src/google/adk/a2a/executor/a2a_agent_executor_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
from a2a.server.agent_execution import AgentExecutor
from a2a.server.agent_execution.context import RequestContext
from a2a.server.events.event_queue import EventQueue
from a2a.types import Artifact
from a2a.types import Message
from a2a.types import Part
from a2a.types import Role
from a2a.types import Task
from a2a.types import TaskState
Expand All @@ -49,7 +47,6 @@
from ..experimental import a2a_experimental
from .config import A2aAgentExecutorConfig
from .executor_context import ExecutorContext
from .interceptors.include_artifacts_in_a2a_event import include_artifacts_in_a2a_event_interceptor
from .utils import execute_after_agent_interceptors
from .utils import execute_after_event_interceptors
from .utils import execute_before_agent_interceptors
Expand Down
1 change: 0 additions & 1 deletion src/google/adk/a2a/executor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from ..converters.part_converter import GenAIPartToA2APartConverter
from ..converters.request_converter import A2ARequestToAgentRunRequestConverter
from ..converters.request_converter import convert_a2a_request_to_agent_run_request
from ..converters.utils import _get_adk_metadata_key
from ..experimental import a2a_experimental
from .executor_context import ExecutorContext

Expand Down
2 changes: 1 addition & 1 deletion src/google/adk/a2a/executor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from a2a.types import TaskStatusUpdateEvent

from ...events.event import Event
from ..converters.utils import _get_adk_metadata_key
from ..converters.utils import _get_adk_metadata_key as _get_adk_metadata_key
from .config import ExecuteInterceptor
from .executor_context import ExecutorContext

Expand Down
1 change: 0 additions & 1 deletion src/google/adk/a2a/utils/agent_to_a2a.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from ...sessions.in_memory_session_service import InMemorySessionService
from ...workflow import Workflow
from ..executor.a2a_agent_executor import A2aAgentExecutor
from ..executor.config import A2aAgentExecutorConfig
from ..experimental import a2a_experimental
from .agent_card_builder import AgentCardBuilder

Expand Down
2 changes: 0 additions & 2 deletions src/google/adk/agents/base_agent_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from typing import List
from typing import Literal
from typing import Optional
from typing import Type
from typing import TYPE_CHECKING
from typing import TypeVar
from typing import Union

Expand Down
2 changes: 1 addition & 1 deletion src/google/adk/agents/callback_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from __future__ import annotations

from .context import Context

# Keep ReadonlyContext for backward compatibility
from .readonly_context import ReadonlyContext

# CallbackContext is unified into Context
CallbackContext = Context
6 changes: 3 additions & 3 deletions src/google/adk/agents/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

if TYPE_CHECKING:
from google.genai import types
from pydantic import BaseModel

from ..artifacts.base_artifact_service import ArtifactVersion
from ..auth.auth_credential import AuthCredential
Expand Down Expand Up @@ -220,12 +219,13 @@ def __init__(
parent_ctx.isolation_scope if parent_ctx else None
)

self._output_for_ancestors: list[str]
if use_as_output and parent_ctx:
self._output_for_ancestors: list[str] = [parent_ctx.node_path] + list(
self._output_for_ancestors = [parent_ctx.node_path] + list(
parent_ctx._output_for_ancestors or []
)
else:
self._output_for_ancestors: list[str] = []
self._output_for_ancestors = []
self._error: Exception | None = None
self._error_node_path: str = ''

Expand Down
1 change: 0 additions & 1 deletion src/google/adk/agents/live_request_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from google.genai import types
from pydantic import BaseModel
from pydantic import ConfigDict
from pydantic import field_validator


class LiveRequest(BaseModel):
Expand Down
1 change: 0 additions & 1 deletion src/google/adk/agents/llm/task/_finish_task_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from ....tools.base_tool import BaseTool
from ....utils._schema_utils import SchemaType
from ._task_models import _DefaultTaskOutput
from ._task_models import TaskResult

if TYPE_CHECKING:
from ....models.llm_request import LlmRequest
Expand Down
5 changes: 0 additions & 5 deletions src/google/adk/agents/remote_a2a_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,17 @@
from a2a.client.client import ClientConfig as A2AClientConfig
from a2a.client.client_factory import ClientFactory as A2AClientFactory
from a2a.client.errors import A2AClientHTTPError
from a2a.client.middleware import ClientCallContext
from a2a.types import AgentCard
from a2a.types import Message as A2AMessage
from a2a.types import MessageSendConfiguration
from a2a.types import Part as A2APart
from a2a.types import Role
from a2a.types import Task as A2ATask
from a2a.types import TaskArtifactUpdateEvent as A2ATaskArtifactUpdateEvent
from a2a.types import TaskState
from a2a.types import TaskStatusUpdateEvent as A2ATaskStatusUpdateEvent
from a2a.types import TransportProtocol as A2ATransport
from google.adk.platform import uuid as platform_uuid
from google.genai import types as genai_types
import httpx
from pydantic import BaseModel

try:
from a2a.utils.constants import AGENT_CARD_WELL_KNOWN_PATH
Expand All @@ -68,7 +64,6 @@
from ..a2a.converters.to_adk_event import _create_mock_function_call_for_required_user_input
from ..a2a.converters.to_adk_event import MOCK_FUNCTION_CALL_FOR_REQUIRED_USER_AUTH
from ..a2a.converters.to_adk_event import MOCK_FUNCTION_CALL_FOR_REQUIRED_USER_INPUT
from ..a2a.converters.utils import _get_adk_metadata_key
from ..a2a.experimental import a2a_experimental
from ..a2a.logs.log_utils import build_a2a_request_log
from ..a2a.logs.log_utils import build_a2a_response_log
Expand Down
2 changes: 0 additions & 2 deletions src/google/adk/apps/base_events_summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import abc
from typing import Optional

from google.genai.types import Content

from ..events.event import Event
from ..utils.feature_decorator import experimental

Expand Down
1 change: 0 additions & 1 deletion src/google/adk/apps/llm_event_summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from typing import Optional

from google.genai import types
from google.genai.types import Content
from google.genai.types import Part

Expand Down
1 change: 0 additions & 1 deletion src/google/adk/artifacts/base_artifact_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from abc import ABC
from abc import abstractmethod
from datetime import datetime
import logging
from typing import Any
from typing import Optional
Expand Down
1 change: 0 additions & 1 deletion src/google/adk/auth/credential_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from .auth_tool import AuthConfig
from .base_auth_provider import BaseAuthProvider
from .exchanger.base_credential_exchanger import BaseCredentialExchanger
from .exchanger.base_credential_exchanger import ExchangeResult
from .exchanger.credential_exchanger_registry import CredentialExchangerRegistry
from .oauth2_discovery import OAuth2DiscoveryManager
from .refresher.credential_refresher_registry import CredentialRefresherRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from .base_credential_exchanger import ExchangeResult

try:
from authlib.integrations.requests_client import OAuth2Session
from authlib.integrations.requests_client import OAuth2Session # noqa: F401

AUTHLIB_AVAILABLE = True
except ImportError:
Expand Down
3 changes: 0 additions & 3 deletions src/google/adk/auth/refresher/oauth2_credential_refresher.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from __future__ import annotations

import json
import logging
from typing import Optional

Expand All @@ -25,8 +24,6 @@
from google.adk.auth.oauth2_credential_util import create_oauth2_session
from google.adk.auth.oauth2_credential_util import update_credential_with_tokens
from google.adk.utils.feature_decorator import experimental
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from typing_extensions import override

from .base_credential_refresher import BaseCredentialRefresher
Expand Down
4 changes: 2 additions & 2 deletions src/google/adk/cli/adk_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

from typing_extensions import deprecated

from .api_server import _parse_cors_origins
from .api_server import RunAgentRequest
from .api_server import _parse_cors_origins as _parse_cors_origins
from .api_server import RunAgentRequest as RunAgentRequest
from .dev_server import DevServer
from .utils.base_agent_loader import BaseAgentLoader as BaseAgentLoader

Expand Down
2 changes: 0 additions & 2 deletions src/google/adk/cli/agent_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,9 @@ def rebuild_tests(path: str):
"""Discovers test files and rebuilds them by running the agent live."""
import json
import sys
import time

from google.adk.apps.app import App
from google.adk.events.event import Event as AdkEvent
from google.genai import types

path_obj = Path(path)
if path_obj.is_dir():
Expand Down
1 change: 0 additions & 1 deletion src/google/adk/cli/built_in_agents/tools/delete_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from __future__ import annotations

from datetime import datetime
from pathlib import Path
import shutil
from typing import Any
from typing import Dict
Expand Down
1 change: 0 additions & 1 deletion src/google/adk/cli/built_in_agents/tools/read_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from __future__ import annotations

from pathlib import Path
from typing import Any
from typing import Dict
from typing import List
Expand Down
8 changes: 4 additions & 4 deletions src/google/adk/cli/cli_tools_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ def cli_eval(
logs.setup_adk_logger(getattr(logging, log_level.upper()))

try:
import importlib
import importlib # noqa: F401

from ..evaluation.base_eval_service import InferenceConfig
from ..evaluation.base_eval_service import InferenceRequest
Expand Down Expand Up @@ -1215,14 +1215,14 @@ def cli_optimize(
logs.setup_adk_logger(getattr(logging, log_level.upper()))

try:
from ..evaluation.custom_metric_evaluator import _CustomMetricEvaluator
from ..evaluation.custom_metric_evaluator import _CustomMetricEvaluator # noqa: F401
from ..evaluation.local_eval_sets_manager import LocalEvalSetsManager
from ..optimization.gepa_root_agent_prompt_optimizer import GEPARootAgentPromptOptimizer
from ..optimization.gepa_root_agent_prompt_optimizer import GEPARootAgentPromptOptimizerConfig
from ..optimization.local_eval_sampler import LocalEvalSampler
from ..optimization.local_eval_sampler import LocalEvalSamplerConfig
from .cli_eval import _collect_eval_results
from .cli_eval import _collect_inferences
from .cli_eval import _collect_eval_results # noqa: F401
from .cli_eval import _collect_inferences # noqa: F401
from .cli_eval import get_root_agent

except ModuleNotFoundError as mnf:
Expand Down
1 change: 0 additions & 1 deletion src/google/adk/cli/conformance/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from pathlib import Path
import textwrap
from typing import Optional
Expand Down
Loading
Loading