ToolFunction

Trait ToolFunction 

pub trait ToolFunction:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn parameters(&self) -> Option<Value>;
    fn call<'life0, 'async_trait>(
        &'life0 self,
        args: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn requires_confirmation(&self) -> bool { ... }
    fn confirmation_message(&self) -> Option<&str> { ... }
}
Expand description

A regular tool — called once, returns a result.

§Examples

use async_trait::async_trait;
use gemini_adk_rs::tool::ToolFunction;
use gemini_adk_rs::error::ToolError;

struct MyTool;

#[async_trait]
impl ToolFunction for MyTool {
    fn name(&self) -> &str { "my_tool" }
    fn description(&self) -> &str { "Does something useful" }
    fn parameters(&self) -> Option<serde_json::Value> { None }
    async fn call(&self, args: serde_json::Value) -> Result<serde_json::Value, ToolError> {
        Ok(serde_json::json!({"status": "ok"}))
    }
}

Required Methods§

fn name(&self) -> &str

The unique name of this tool.

fn description(&self) -> &str

Human-readable description of what this tool does.

fn parameters(&self) -> Option<Value>

JSON Schema for the tool’s input parameters, or None if parameterless.

fn call<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Execute the tool with the given arguments and return the result.

Provided Methods§

fn requires_confirmation(&self) -> bool

Whether this tool must be confirmed before it runs. Defaults to false.

Tools built with T::confirm(..) (a PolicyTool with a confirm policy) return true, prompting the ToolDispatcher to consult its configured ConfirmationProvider before executing.

fn confirmation_message(&self) -> Option<&str>

Optional hint shown when confirmation is requested.

Implementors§

§

impl ToolFunction for PolicyTool

§

impl ToolFunction for SimpleTool

§

impl ToolFunction for AgentTool

§

impl ToolFunction for ExecuteBashTool

§

impl ToolFunction for ExitLoopTool

§

impl ToolFunction for GetUserChoiceTool

§

impl ToolFunction for LoadMemoryTool

§

impl ToolFunction for LongRunningFunctionTool

§

impl ToolFunction for McpTool

§

impl ToolFunction for TextAgentTool

§

impl ToolFunction for TransferToAgentTool

§

impl ToolFunction for VertexAiSearchTool

§

impl<T> ToolFunction for TypedTool<T>
where T: DeserializeOwned + JsonSchema + Send + Sync + 'static,