pub struct ReadFileTool { /* private fields */ }Expand description
Reads a file from the workspace: UTF-8 text with line numbers, or a PNG, JPEG, GIF, WebP or PDF as an inline data part the model can look at (spec 3.1 §10 D6).
A file matching the workspace’s exclusion patterns (Workspace::exclude_globs),
by its requested path or the path a symlink resolves to, is refused with
DevToolError::Excluded. On Unix the file is opened without following a symlink on
any component of the target the containment check resolved, and a file with more
than one hard link is refused (spec 3.1 §10 D4). Binary content follows the same rules.
The type comes from the file’s first bytes, never its extension: a text file named
diagram.png is read as text, and notes.txt holding a PNG is returned as an image.
The result of a binary read is { "response": { path, mime_type, bytes, content }, "inline_data": [{ mime_type, data }] }, which the agent loop turns into a function
response with an inline part; content is a stub naming the type and size, so a
provider that cannot take the bytes still learns what the file is. Over
max_inline_bytes, or under text_only,
only the stub is returned. The bytes are never interpreted here (spec 3.1 §9.2 I55).
§Example
use adk_devtools::{ReadFileTool, Workspace};
let read = ReadFileTool::new(Workspace::new("./my-repo")).max_inline_bytes(1024 * 1024);Implementations§
Source§impl ReadFileTool
impl ReadFileTool
Sourcepub fn max_inline_bytes(self, bytes: usize) -> Self
pub fn max_inline_bytes(self, bytes: usize) -> Self
The largest image or PDF returned as inline data; capped at
adk_core::MAX_INLINE_DATA_SIZE. A larger file gets the text stub only.
Trait Implementations§
Source§impl Tool for ReadFileTool
impl Tool for ReadFileTool
Source§fn egress(&self, _args: &Value) -> ToolEgress
fn egress(&self, _args: &Value) -> ToolEgress
Reads a workspace file on disk.
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
Source§fn is_concurrency_safe(&self) -> bool
fn is_concurrency_safe(&self) -> bool
Source§fn parameters_schema(&self) -> Option<Value>
fn parameters_schema(&self) -> Option<Value>
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
ctx: Arc<dyn ToolContext>,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
ctx: Arc<dyn ToolContext>,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn declaration(&self) -> Value
fn declaration(&self) -> Value
Source§fn enhanced_description(&self) -> String
fn enhanced_description(&self) -> String
Source§fn is_long_running(&self) -> bool
fn is_long_running(&self) -> bool
Source§fn is_builtin(&self) -> bool
fn is_builtin(&self) -> bool
google_search, url_context). Read more