Skip to main content

BypassMultiToolsLimit

Trait BypassMultiToolsLimit 

Source
pub trait BypassMultiToolsLimit: Sized {
    // Required methods
    fn bypass_name(&self) -> String;
    fn bypass_description(&self) -> String;
    fn bypass_parameters_schema(&self) -> Value;
    fn bypass_query_field(&self) -> String;

    // Provided method
    fn with_bypass_multi_tools_limit(
        self,
        agent: Arc<dyn Agent>,
    ) -> Arc<dyn Tool>  { ... }
}
Available on crate feature tools only.
Expand description

Generalizes the bypass_multi_tools_limit conversion so any built-in tool can adopt it ergonomically.

The Gemini Interactions API forbids mixing built-in (server-side) tools with custom function tools in a single request. Implementing this trait lets a built-in tool be converted into a function-calling BypassBuiltinTool — reporting is_builtin() == false and declaring a normal function schema — so every tool in the request is uniform.

Implementors only describe what the bypass tool looks like (its name, description, parameter schema, and which argument field carries the query); the shared with_bypass_multi_tools_limit default method performs the actual conversion identically for every tool. This guarantees the conversion is uniform across GoogleSearchTool, UrlContextTool, GeminiFileSearchTool, and any future built-in.

Because adk-tool cannot depend on adk-agent (that would be circular), the internal agent that performs the built-in behaviour is supplied by the caller. It is expected to be an LlmAgent configured with the matching built-in tool and a Gemini model.

§Example

use adk_tool::{BypassMultiToolsLimit, GoogleSearchTool, UrlContextTool};
use std::sync::Arc;

// `search_agent` / `url_agent` are LlmAgents with the matching built-in tool.
let search = GoogleSearchTool::new().with_bypass_multi_tools_limit(Arc::new(search_agent));
let url = UrlContextTool::new().with_bypass_multi_tools_limit(Arc::new(url_agent));
assert!(!search.is_builtin());
assert!(!url.is_builtin());

Required Methods§

Source

fn bypass_name(&self) -> String

The function-tool name surfaced to the model after bypass conversion.

Defaults to the tool’s own Tool::name() and rarely needs overriding.

Source

fn bypass_description(&self) -> String

The function-tool description surfaced to the model.

Source

fn bypass_parameters_schema(&self) -> Value

The JSON Schema for the bypass function’s parameters.

Source

fn bypass_query_field(&self) -> String

The argument field that carries the natural-language query forwarded to the internal agent (e.g. "query" for search, "url" for URL context).

Provided Methods§

Source

fn with_bypass_multi_tools_limit(self, agent: Arc<dyn Agent>) -> Arc<dyn Tool>

Convert this built-in tool into a function-calling BypassBuiltinTool so it can coexist with custom function tools under the Interactions API.

agent is the internal single-turn agent that performs the built-in behaviour and whose answer is returned as the function response.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl BypassMultiToolsLimit for GeminiFileSearchTool

Bypass support: convert the built-in Gemini File Search tool into a function-calling tool so it can be used alongside custom function tools under the Gemini Interactions API.

The converted tool declares a query: string function schema and performs the document search by delegating to an internal single-turn agent (an LlmAgent configured with GeminiFileSearchTool and a Gemini model).

§Example

use adk_tool::{BypassMultiToolsLimit, GeminiFileSearchTool};
use std::sync::Arc;

// `file_search_agent` is an LlmAgent with GeminiFileSearchTool + a Gemini model.
let tool = GeminiFileSearchTool::new(["my-store"])
    .with_bypass_multi_tools_limit(Arc::new(file_search_agent));
assert!(!tool.is_builtin());
Source§

impl BypassMultiToolsLimit for GoogleSearchTool

Bypass support: convert the built-in Google Search tool into a function-calling tool so it can be used alongside custom function tools.

The Gemini Interactions API forbids mixing built-in (server-side) tools with custom function tools in one request. Implementing BypassMultiToolsLimit mirrors ADK-Python’s bypass_multi_tools_limit=True: the converted tool reports is_builtin() == false, declares a normal query: string function schema, and performs grounded search by delegating to an internal single-turn agent.

Because adk-tool cannot depend on adk-agent, the internal grounded-search agent is supplied by the caller. It is expected to be an LlmAgent configured with GoogleSearchTool and a Gemini model so that the grounding happens server-side.

§Example

use adk_tool::{BypassMultiToolsLimit, GoogleSearchTool};
use std::sync::Arc;

// `search_agent` is an LlmAgent with GoogleSearchTool + a Gemini model.
let tool = GoogleSearchTool::new().with_bypass_multi_tools_limit(Arc::new(search_agent));
assert!(!tool.is_builtin());
Source§

impl BypassMultiToolsLimit for UrlContextTool

Bypass support: convert the built-in URL-context tool into a function-calling tool so it can be used alongside custom function tools under the Gemini Interactions API.

The converted tool declares a url: string function schema and performs the fetch-and-analyze behaviour by delegating to an internal single-turn agent (an LlmAgent configured with UrlContextTool and a Gemini model).

§Example

use adk_tool::{BypassMultiToolsLimit, UrlContextTool};
use std::sync::Arc;

// `url_agent` is an LlmAgent with UrlContextTool + a Gemini model.
let tool = UrlContextTool::new().with_bypass_multi_tools_limit(Arc::new(url_agent));
assert!(!tool.is_builtin());