Skip to content

Commit ab4b952

Browse files
wukathcopybara-github
authored andcommitted
chore: Move spanner tools to integration folder
Added a deprecation warning in the old tools/spanner/__init__.py Co-authored-by: Kathy Wu <wukathy@google.com> PiperOrigin-RevId: 878742289
1 parent 2addf6b commit ab4b952

24 files changed

+110
-78
lines changed

contributing/samples/spanner/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Introduction
44

55
This sample agent demonstrates the Spanner first-party tools in ADK,
6-
distributed via the `google.adk.tools.spanner` module. These tools include:
6+
distributed via the `google.adk.integrations.spanner` module. These tools include:
77

88
1. `list_table_names`
99

contributing/samples/spanner/agent.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
from google.adk.agents.llm_agent import LlmAgent
1818
from google.adk.auth.auth_credential import AuthCredentialTypes
19+
from google.adk.integrations.spanner.settings import Capabilities
20+
from google.adk.integrations.spanner.settings import QueryResultMode
21+
from google.adk.integrations.spanner.settings import SpannerToolSettings
22+
from google.adk.integrations.spanner.spanner_credentials import SpannerCredentialsConfig
23+
from google.adk.integrations.spanner.spanner_toolset import SpannerToolset
24+
import google.adk.integrations.spanner.utils as spanner_tool_utils
1925
from google.adk.tools.google_tool import GoogleTool
20-
from google.adk.tools.spanner.settings import Capabilities
21-
from google.adk.tools.spanner.settings import QueryResultMode
22-
from google.adk.tools.spanner.settings import SpannerToolSettings
23-
from google.adk.tools.spanner.spanner_credentials import SpannerCredentialsConfig
24-
from google.adk.tools.spanner.spanner_toolset import SpannerToolset
25-
import google.adk.tools.spanner.utils as spanner_tool_utils
2626
from google.adk.tools.tool_context import ToolContext
2727
import google.auth
2828
from google.auth.credentials import Credentials

contributing/samples/spanner_rag_agent/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This sample demonstrates how to build an intelligent Retrieval Augmented
66
Generation (RAG) agent using the flexible, built-in Spanner tools available
7-
in the ADK's `google.adk.tools.spanner` module, including how to create
7+
in the ADK's `google.adk.integrations.spanner` module, including how to create
88
customized Spanner tools by extending the existing ones.
99

1010
[Spanner](https://cloud.google.com/spanner/docs) is a fully managed,
@@ -199,10 +199,10 @@ There are a few options to perform similarity search:
199199

200200
```py
201201
from google.adk.agents.llm_agent import LlmAgent
202-
from google.adk.tools.spanner.settings import Capabilities
203-
from google.adk.tools.spanner.settings import SpannerToolSettings
204-
from google.adk.tools.spanner.settings import SpannerVectorStoreSettings
205-
from google.adk.tools.spanner.spanner_toolset import SpannerToolset
202+
from google.adk.integrations.spanner.settings import Capabilities
203+
from google.adk.integrations.spanner.settings import SpannerToolSettings
204+
from google.adk.integrations.spanner.settings import SpannerVectorStoreSettings
205+
from google.adk.integrations.spanner.spanner_toolset import SpannerToolset
206206

207207
# credentials_config = SpannerCredentialsConfig(...)
208208

@@ -267,9 +267,9 @@ There are a few options to perform similarity search:
267267

268268
```py
269269
from google.adk.agents.llm_agent import LlmAgent
270-
from google.adk.tools.spanner.settings import Capabilities
271-
from google.adk.tools.spanner.settings import SpannerToolSettings
272-
from google.adk.tools.spanner.spanner_toolset import SpannerToolset
270+
from google.adk.integrations.spanner.settings import Capabilities
271+
from google.adk.integrations.spanner.settings import SpannerToolSettings
272+
from google.adk.integrations.spanner.spanner_toolset import SpannerToolset
273273

274274
# credentials_config = SpannerCredentialsConfig(...)
275275

@@ -312,7 +312,7 @@ There are a few options to perform similarity search:
312312
from google.adk.agents.llm_agent import LlmAgent
313313

314314
from google.adk.tools.google_tool import GoogleTool
315-
from google.adk.tools.spanner import search_tool
315+
from google.adk.integrations.spanner import search_tool
316316
import google.auth
317317
from google.auth.credentials import Credentials
318318

contributing/samples/spanner_rag_agent/agent.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
from google.adk.agents.llm_agent import LlmAgent
1818
from google.adk.auth.auth_credential import AuthCredentialTypes
19-
from google.adk.tools.spanner.settings import Capabilities
20-
from google.adk.tools.spanner.settings import SpannerToolSettings
21-
from google.adk.tools.spanner.settings import SpannerVectorStoreSettings
22-
from google.adk.tools.spanner.spanner_credentials import SpannerCredentialsConfig
23-
from google.adk.tools.spanner.spanner_toolset import SpannerToolset
19+
from google.adk.integrations.spanner.settings import Capabilities
20+
from google.adk.integrations.spanner.settings import SpannerToolSettings
21+
from google.adk.integrations.spanner.settings import SpannerVectorStoreSettings
22+
from google.adk.integrations.spanner.spanner_credentials import SpannerCredentialsConfig
23+
from google.adk.integrations.spanner.spanner_toolset import SpannerToolset
2424
import google.auth
2525

2626
# Define an appropriate credential type
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2026 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+
"""Spanner Tools (Experimental).
16+
17+
Spanner Tools under this module are hand crafted and customized while the tools
18+
under google.adk.tools.google_api_tool are auto generated based on API
19+
definition. The rationales to have customized tool are:
20+
21+
1. A dedicated Spanner toolset to provide an easier, integrated way to interact
22+
with Spanner database and tables for building AI Agent applications quickly.
23+
2. We want to provide more high-level tools like Search, ML.Predict, and Graph
24+
etc.
25+
3. We want to provide extra access guardrails and controls in those tools.
26+
For example, execute_sql can't arbitrarily mutate existing data.
27+
4. We want to provide Spanner best practices and knowledge assistants for ad-hoc
28+
analytics queries.
29+
5. Use Spanner Toolset for more customization and control to interact with
30+
Spanner database and tables.
31+
"""
32+
33+
from . import spanner_credentials
34+
from .spanner_toolset import SpannerToolset
35+
36+
SpannerCredentialsConfig = spanner_credentials.SpannerCredentialsConfig
37+
__all__ = [
38+
"SpannerToolset",
39+
"SpannerCredentialsConfig",
40+
]
File renamed without changes.
File renamed without changes.

src/google/adk/tools/spanner/query_tool.py renamed to src/google/adk/integrations/spanner/query_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from google.auth.credentials import Credentials
2323

2424
from . import utils
25-
from ..tool_context import ToolContext
25+
from ...tools.tool_context import ToolContext
2626
from .settings import QueryResultMode
2727
from .settings import SpannerToolSettings
2828

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)