use crate::builtin::bypass::BypassMultiToolsLimit;
use adk_core::{Result, Tool, ToolContext};
use async_trait::async_trait;
use serde_json::{Value, json};
use std::sync::Arc;
#[derive(Default)]
pub struct GoogleSearchTool;
impl GoogleSearchTool {
pub fn new() -> Self {
Self
}
}
impl BypassMultiToolsLimit for GoogleSearchTool {
fn bypass_name(&self) -> String {
self.name().to_string()
}
fn bypass_description(&self) -> String {
"Performs a Google search to retrieve information from the web.".to_string()
}
fn bypass_parameters_schema(&self) -> Value {
json!({
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query to look up on Google."
}
},
"required": ["query"]
})
}
fn bypass_query_field(&self) -> String {
"query".to_string()
}
}
#[async_trait]
impl Tool for GoogleSearchTool {
fn name(&self) -> &str {
"google_search"
}
fn description(&self) -> &str {
"Performs a Google search to retrieve information from the web."
}
fn is_builtin(&self) -> bool {
true
}
fn declaration(&self) -> Value {
json!({
"name": self.name(),
"description": self.description(),
"x-adk-gemini-tool": {
"google_search": {}
}
})
}
async fn execute(&self, _ctx: Arc<dyn ToolContext>, _args: Value) -> Result<Value> {
Err(adk_core::AdkError::tool("GoogleSearch is handled internally by Gemini"))
}
}