Skip to main content

ToolCallScreen

Trait ToolCallScreen 

Source
pub trait ToolCallScreen: Send + Sync {
    // Required method
    fn screen<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tool_name: &'life1 str,
        args: &'life2 Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
}
Expand description

Core traits and types.

Always available regardless of feature flags. Includes:

  • Agent - The fundamental trait for all agents
  • Tool / Toolset - For extending agents with capabilities
  • Session / State - For managing conversation context
  • Event - For streaming agent responses
  • AdkError / Result - Unified error handling Screens a tool call’s final arguments, as an agent’s tool guardrails do.

§Example

use adk_core::{ToolCallScreen, async_trait};
use serde_json::Value;

struct NoRoot;

#[async_trait]
impl ToolCallScreen for NoRoot {
    async fn screen(&self, _tool: &str, args: &Value) -> Result<Value, String> {
        if args["path"] == "/" { Err("refusing to touch /".into()) } else { Ok(args.clone()) }
    }
}

Required Methods§

Source

fn screen<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tool_name: &'life1 str, args: &'life2 Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Returns the arguments to continue with, possibly rewritten, or the reason the call is refused.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§