Skip to main content

ToolService

Trait ToolService 

Source
pub trait ToolService: Send + Sync {
    // Required method
    fn exec_for(&self, entity: Entity, calls: Vec<ToolCall>) -> BoxedToolExec;

    // Provided methods
    fn sync_stage(
        &self,
        _entity: Entity,
        _stage_index: usize,
        _stage_name: &str,
    ) { ... }
    fn refresh_tools(
        &self,
        _entity: Entity,
        _stage_index: usize,
    ) -> Option<Vec<Tool>> { ... }
    fn wants_refresh(&self, _entity: Entity) -> bool { ... }
}
Expand description

Provides a per-agent tool-execution closure. The concrete implementation (in the CLI) holds each agent’s tool registry, workdir, and permission policy; the pipeline stays agnostic to how tools run. exec_for returns a boxed closure the tool worker runs off the tick.

Required Methods§

Source

fn exec_for(&self, entity: Entity, calls: Vec<ToolCall>) -> BoxedToolExec

Build the closure that runs calls for entity, resolving (id, result) pairs.

Provided Methods§

Source

fn sync_stage(&self, _entity: Entity, _stage_index: usize, _stage_name: &str)

Notify the service that entity entered the stage at stage_index named stage_name, so it can re-sync that agent’s per-stage tool permissions. Default no-op for services without per-stage policy.

Source

fn refresh_tools( &self, _entity: Entity, _stage_index: usize, ) -> Option<Vec<Tool>>

Re-resolve entity’s advertised tool defs for the stage at stage_index - e.g. after new tools were discovered on disk. None means “no change” (the default, for services without dynamic tools); Some(tools) replaces the stage’s advertised set.

Source

fn wants_refresh(&self, _entity: Entity) -> bool

Whether entity (a dynamic_tools agent) has pending tool changes that warrant a re-scan + re-advertise. Polled by poll_dynamic_tool_refresh; implementors return (and clear) a per-agent dirty flag. Default false.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§