Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
from ....types.interactions.thoughtsummarydelta import (
ThoughtSummaryDelta as ThoughtSummary,
)
from ....types.interactions.toolsearchcalldelta import (
ToolSearchCallDelta as ToolSearchCall,
)
from ....types.interactions.toolsearchresultdelta import (
ToolSearchResultDelta as ToolSearchResult,
)
from ....types.interactions.urlcontextcalldelta import (
URLContextCallDelta as URLContextCall,
)
Expand Down Expand Up @@ -91,6 +97,8 @@
"TextAnnotationDelta",
"ThoughtSignature",
"ThoughtSummary",
"ToolSearchCall",
"ToolSearchResult",
"URLContextCall",
"URLContextResult",
"Video",
Expand Down
2 changes: 2 additions & 0 deletions google/genai/_gaos/resources/interactions/tool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from ....types.interactions.googlesearch import GoogleSearch
from ....types.interactions.mcpserver import MCPServer
from ....types.interactions.retrieval import Retrieval
from ....types.interactions.toolsearch import ToolSearch
from ....types.interactions.urlcontext import URLContext
from . import retrieval

Expand All @@ -34,6 +35,7 @@
"GoogleSearch",
"MCPServer",
"Retrieval",
"ToolSearch",
"URLContext",
"retrieval",
]
28 changes: 28 additions & 0 deletions google/genai/_gaos/types/interactions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,16 @@
from .tool import Tool, ToolParam, UnknownTool
from .toolchoiceconfig import ToolChoiceConfig, ToolChoiceConfigParam
from .toolchoicetype import ToolChoiceType
from .toolsearch import Execution, ToolSearch, ToolSearchParam
from .toolsearchcalldelta import ToolSearchCallDelta, ToolSearchCallDeltaTypedDict
from .toolsearchcallsteparguments import (
ToolSearchCallStepArguments,
ToolSearchCallStepArgumentsTypedDict,
)
from .toolsearchresultdelta import (
ToolSearchResultDelta,
ToolSearchResultDeltaTypedDict,
)
from .transcriptionconfig import TranscriptionConfig, TranscriptionConfigParam
from .urlcitation import URLCitation, URLCitationParam
from .urlcontext import URLContext, URLContextParam
Expand Down Expand Up @@ -488,6 +498,7 @@
"ErrorTypedDict",
"ExaAISearchConfig",
"ExaAISearchConfigParam",
"Execution",
"FileCitation",
"FileCitationParam",
"FileContent",
Expand Down Expand Up @@ -730,6 +741,14 @@
"ToolChoiceParam",
"ToolChoiceType",
"ToolParam",
"ToolSearch",
"ToolSearchCallDelta",
"ToolSearchCallDeltaTypedDict",
"ToolSearchCallStepArguments",
"ToolSearchCallStepArgumentsTypedDict",
"ToolSearchParam",
"ToolSearchResultDelta",
"ToolSearchResultDeltaTypedDict",
"TranscriptionConfig",
"TranscriptionConfigParam",
"Transform",
Expand Down Expand Up @@ -1115,6 +1134,15 @@
"ToolChoiceConfig": ".toolchoiceconfig",
"ToolChoiceConfigParam": ".toolchoiceconfig",
"ToolChoiceType": ".toolchoicetype",
"Execution": ".toolsearch",
"ToolSearch": ".toolsearch",
"ToolSearchParam": ".toolsearch",
"ToolSearchCallDelta": ".toolsearchcalldelta",
"ToolSearchCallDeltaTypedDict": ".toolsearchcalldelta",
"ToolSearchCallStepArguments": ".toolsearchcallsteparguments",
"ToolSearchCallStepArgumentsTypedDict": ".toolsearchcallsteparguments",
"ToolSearchResultDelta": ".toolsearchresultdelta",
"ToolSearchResultDeltaTypedDict": ".toolsearchresultdelta",
"TranscriptionConfig": ".transcriptionconfig",
"TranscriptionConfigParam": ".transcriptionconfig",
"URLCitation": ".urlcitation",
Expand Down
18 changes: 17 additions & 1 deletion google/genai/_gaos/types/interactions/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,27 @@
class FunctionParam(TypedDict):
r"""A tool that can be used by the model."""

defer_loading: NotRequired[bool]
r"""If true, the function's loading is deferred."""
description: NotRequired[str]
r"""A description of the function."""
name: NotRequired[str]
r"""The name of the function."""
parameters: NotRequired[Any]
r"""The JSON Schema for the function's parameters."""
short_description: NotRequired[str]
r"""A brief description of the function, shown to the model as a
short summary of functions with `defer_loading` set to true.
"""
type: Literal["function"]


class Function(BaseModel):
r"""A tool that can be used by the model."""

defer_loading: Optional[bool] = None
r"""If true, the function's loading is deferred."""

description: Optional[str] = None
r"""A description of the function."""

Expand All @@ -50,14 +59,21 @@ class Function(BaseModel):
parameters: Optional[Any] = None
r"""The JSON Schema for the function's parameters."""

short_description: Optional[str] = None
r"""A brief description of the function, shown to the model as a
short summary of functions with `defer_loading` set to true.
"""

type: Annotated[
Annotated[Literal["function"], AfterValidator(validate_const("function"))],
pydantic.Field(alias="type"),
] = "function"

@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["description", "name", "parameters"])
optional_fields = set(
["defer_loading", "description", "name", "parameters", "short_description"]
)
serialized = handler(self)
m = {}

Expand Down
9 changes: 8 additions & 1 deletion google/genai/_gaos/types/interactions/mcpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class MCPServerParam(TypedDict):

allowed_tools: NotRequired[List[AllowedToolsParam]]
r"""The allowed tools."""
defer_loading: NotRequired[bool]
r"""If true, loading of tools on this MCP server is deferred."""
headers: NotRequired[Dict[str, str]]
r"""Optional: Fields for authentication headers, timeouts, etc., if needed."""
name: NotRequired[str]
Expand All @@ -49,6 +51,9 @@ class MCPServer(BaseModel):
allowed_tools: Optional[List[AllowedTools]] = None
r"""The allowed tools."""

defer_loading: Optional[bool] = None
r"""If true, loading of tools on this MCP server is deferred."""

headers: Optional[Dict[str, str]] = None
r"""Optional: Fields for authentication headers, timeouts, etc., if needed."""

Expand All @@ -67,7 +72,9 @@ class MCPServer(BaseModel):

@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["allowed_tools", "headers", "name", "url"])
optional_fields = set(
["allowed_tools", "defer_loading", "headers", "name", "url"]
)
serialized = handler(self)
m = {}

Expand Down
12 changes: 10 additions & 2 deletions google/genai/_gaos/types/interactions/stepdeltadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
from .textdelta import TextDelta, TextDeltaTypedDict
from .thoughtsignaturedelta import ThoughtSignatureDelta, ThoughtSignatureDeltaTypedDict
from .thoughtsummarydelta import ThoughtSummaryDelta, ThoughtSummaryDeltaTypedDict
from .toolsearchcalldelta import ToolSearchCallDelta, ToolSearchCallDeltaTypedDict
from .toolsearchresultdelta import ToolSearchResultDelta, ToolSearchResultDeltaTypedDict
from .urlcontextcalldelta import URLContextCallDelta, URLContextCallDeltaTypedDict
from .urlcontextresultdelta import URLContextResultDelta, URLContextResultDeltaTypedDict
from .videodelta import VideoDelta, VideoDeltaTypedDict
Expand Down Expand Up @@ -80,13 +82,15 @@
GoogleMapsResultDeltaTypedDict,
GoogleSearchCallDeltaTypedDict,
URLContextCallDeltaTypedDict,
ToolSearchResultDeltaTypedDict,
ToolSearchCallDeltaTypedDict,
CodeExecutionCallDeltaTypedDict,
GoogleSearchResultDeltaTypedDict,
MCPServerToolResultDeltaTypedDict,
RetrievalCallDeltaTypedDict,
MCPServerToolCallDeltaTypedDict,
DocumentDeltaTypedDict,
CodeExecutionResultDeltaTypedDict,
MCPServerToolResultDeltaTypedDict,
MCPServerToolCallDeltaTypedDict,
URLContextResultDeltaTypedDict,
ImageDeltaTypedDict,
FunctionResultDeltaTypedDict,
Expand Down Expand Up @@ -128,6 +132,8 @@ class UnknownStepDeltaData(BaseModel):
"text": TextDelta,
"thought_signature": ThoughtSignatureDelta,
"thought_summary": ThoughtSummaryDelta,
"tool_search_call": ToolSearchCallDelta,
"tool_search_result": ToolSearchResultDelta,
"url_context_call": URLContextCallDelta,
"url_context_result": URLContextResultDelta,
"video": VideoDelta,
Expand Down Expand Up @@ -157,6 +163,8 @@ class UnknownStepDeltaData(BaseModel):
TextDelta,
ThoughtSignatureDelta,
ThoughtSummaryDelta,
ToolSearchCallDelta,
ToolSearchResultDelta,
URLContextCallDelta,
URLContextResultDelta,
VideoDelta,
Expand Down
6 changes: 5 additions & 1 deletion google/genai/_gaos/types/interactions/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .googlesearch import GoogleSearch, GoogleSearchParam
from .mcpserver import MCPServer, MCPServerParam
from .retrieval import Retrieval, RetrievalParam
from .toolsearch import ToolSearch, ToolSearchParam
from .urlcontext import URLContext, URLContextParam
from functools import partial
from .. import BaseModel
Expand All @@ -42,9 +43,10 @@
URLContextParam,
GoogleSearchParam,
FileSearchParam,
FunctionParam,
GoogleMapsParam,
ComputerUseParam,
ToolSearchParam,
FunctionParam,
MCPServerParam,
RetrievalParam,
],
Expand All @@ -71,6 +73,7 @@ class UnknownTool(BaseModel):
"google_search": GoogleSearch,
"mcp_server": MCPServer,
"retrieval": Retrieval,
"tool_search": ToolSearch,
"url_context": URLContext,
}

Expand All @@ -85,6 +88,7 @@ class UnknownTool(BaseModel):
GoogleSearch,
MCPServer,
Retrieval,
ToolSearch,
URLContext,
UnknownTool,
],
Expand Down
105 changes: 105 additions & 0 deletions google/genai/_gaos/types/interactions/toolsearch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pyformat: disable

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .. import BaseModel, UNSET_SENTINEL, UnrecognizedStr
from ...utils import validate_const
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import AfterValidator
from typing import Any, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict


Execution = Union[
Literal[
"server",
"client",
],
UnrecognizedStr,
]
r"""The execution mode of the tool search."""


class ToolSearchParam(TypedDict):
r"""A tool that allows the model to dynamically search for and load tools into
the model’s context on demand. This allows clients to avoid loading all tool
definitions up front and may help reduce overall token usage and cost.
"""

description: NotRequired[str]
r"""A description of the function. To be set only for client-side execution."""
execution: NotRequired[Execution]
r"""The execution mode of the tool search."""
name: NotRequired[str]
r"""The name of the function. To be set only for client-side execution."""
parameters: NotRequired[Any]
r"""The JSON Schema for the function's parameters. To be set only for
client-side execution.
"""
type: Literal["tool_search"]


class ToolSearch(BaseModel):
r"""A tool that allows the model to dynamically search for and load tools into
the model’s context on demand. This allows clients to avoid loading all tool
definitions up front and may help reduce overall token usage and cost.
"""

description: Optional[str] = None
r"""A description of the function. To be set only for client-side execution."""

execution: Optional[Execution] = None
r"""The execution mode of the tool search."""

name: Optional[str] = None
r"""The name of the function. To be set only for client-side execution."""

parameters: Optional[Any] = None
r"""The JSON Schema for the function's parameters. To be set only for
client-side execution.
"""

type: Annotated[
Annotated[
Literal["tool_search"], AfterValidator(validate_const("tool_search"))
],
pydantic.Field(alias="type"),
] = "tool_search"

@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["description", "execution", "name", "parameters"])
serialized = handler(self)
m = {}

for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k, serialized.get(n))

if val != UNSET_SENTINEL:
if val is not None or k not in optional_fields:
m[k] = val

return m


try:
ToolSearch.model_rebuild()
except NameError:
pass
Loading
Loading