adk_tool/builtin/
url_context.rs1use crate::builtin::bypass::BypassMultiToolsLimit;
2use adk_core::{Result, Tool, ToolContext};
3use async_trait::async_trait;
4use serde_json::{Value, json};
5use std::sync::Arc;
6
7#[derive(Default)]
12pub struct UrlContextTool;
13
14impl UrlContextTool {
15 pub fn new() -> Self {
17 Self
18 }
19}
20
21impl BypassMultiToolsLimit for UrlContextTool {
40 fn bypass_name(&self) -> String {
41 self.name().to_string()
42 }
43
44 fn bypass_description(&self) -> String {
45 "Fetches and analyzes content from a URL to provide context.".to_string()
46 }
47
48 fn bypass_parameters_schema(&self) -> Value {
49 json!({
50 "type": "object",
51 "properties": {
52 "url": {
53 "type": "string",
54 "description": "The URL whose content should be fetched and analyzed."
55 }
56 },
57 "required": ["url"]
58 })
59 }
60
61 fn bypass_query_field(&self) -> String {
62 "url".to_string()
63 }
64}
65
66#[async_trait]
67impl Tool for UrlContextTool {
68 fn name(&self) -> &str {
69 "url_context"
70 }
71
72 fn description(&self) -> &str {
73 "Fetches and analyzes content from URLs to provide context."
74 }
75
76 fn is_builtin(&self) -> bool {
77 true
78 }
79
80 fn declaration(&self) -> Value {
81 json!({
82 "name": self.name(),
83 "description": self.description(),
84 "x-adk-gemini-tool": {
85 "url_context": {}
86 }
87 })
88 }
89
90 async fn execute(&self, _ctx: Arc<dyn ToolContext>, _args: Value) -> Result<Value> {
91 Err(adk_core::AdkError::tool("UrlContext is handled internally by Gemini"))
92 }
93}