Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn spec(&self) -> ToolSpec;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        arguments: Value,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn side_effect_class(&self) -> ToolSideEffect { ... }
    fn is_deferred(&self) -> bool { ... }
    fn kind(&self) -> ToolKind { ... }
    fn is_readonly(&self) -> bool { ... }
    fn is_readonly_for_args(&self, _arguments: &Value) -> bool { ... }
}

Required Methods§

Source

fn spec(&self) -> ToolSpec

Source

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

Provided Methods§

Source

fn side_effect_class(&self) -> ToolSideEffect

Classify this tool’s observable side-effects. Default is the most conservative value (External) so any unannotated tool is treated as risky on resume. Override to ReadOnly or Mutating for built-in tools; MCP tools derive this from their annotations.

Source

fn is_deferred(&self) -> bool

Return true to send this tool as deferred (name-only) in the initial prompt; the model must call ToolSearch to load its full schema. Default is false (eager). Override in low-frequency tools.

Source

fn kind(&self) -> ToolKind

Return the ACP ToolKind for tool_call notifications (Sprint 3). Defaults to ToolKind::Other. Concrete tools override to map to their corresponding ACP category.

Source

fn is_readonly(&self) -> bool

Convenience: a tool is read-only iff it classifies as ReadOnly. Used by the parallel-dispatch path in agent.rs. Override only if you have an unusual reason (you almost never should — override side_effect_class instead and let this default through).

Source

fn is_readonly_for_args(&self, _arguments: &Value) -> bool

Like is_readonly but can inspect the call-time arguments.

Override this when read-only-ness depends on parameters (e.g. sub_agent with subagent_type: "explore" behaves as read-only while "general_purpose" is not). The default delegates to is_readonly().

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Tool for A2aCallTool

Source§

impl Tool for A2aCardTool

Source§

impl Tool for A2aTaskCheckTool

Source§

impl Tool for AgentTool

Source§

impl Tool for CheckBackground

Source§

impl Tool for CheckpointDiff

Source§

impl Tool for CheckpointList

Source§

impl Tool for CheckpointSave

Source§

impl Tool for ClientReadFile

Source§

impl Tool for ClientWriteFile

Source§

impl Tool for CountLines

Source§

impl Tool for EditTool

Source§

impl Tool for EnterPlanModeTool

Source§

impl Tool for EpisodicRecall

Source§

impl Tool for EstimateTokens

Source§

impl Tool for ExitPlanModeTool

Source§

impl Tool for Forget

Source§

impl Tool for ForgetFact

Source§

impl Tool for GlobTool

Source§

impl Tool for InstallSkill

Source§

impl Tool for ListWorkersTool

Source§

impl Tool for LoadSkill

Source§

impl Tool for McpTool

Source§

impl Tool for ReadFile

Source§

impl Tool for Recall

Source§

impl Tool for RecallFact

Source§

impl Tool for Remember

Source§

impl Tool for RememberFact

Source§

impl Tool for RequestPlanModeTool

Source§

impl Tool for RunBackground

Source§

impl Tool for RunShell

Source§

impl Tool for ScheduleWakeup

Source§

impl Tool for ScratchpadDelete

Source§

impl Tool for ScratchpadGet

Source§

impl Tool for ScratchpadList

Source§

impl Tool for SearchFiles

Source§

impl Tool for SendMessageTool

Source§

impl Tool for SharedMemoryRead

Source§

impl Tool for SharedMemoryWrite

Source§

impl Tool for StopLoop

Source§

impl Tool for TodoWriteTool

Source§

impl Tool for ToolSearchTool

Source§

impl Tool for UpdateFact

Source§

impl Tool for WatchFile

Source§

impl Tool for WebFetch

Source§

impl Tool for WebSearch

Source§

impl Tool for WorkingMemoryTool

Source§

impl Tool for WriteFile