Skip to main content

Module agent_tool

Module agent_tool 

Source
Expand description

Mirrors the tool-definition portion of packages/agent/src/types.ts (AgentTool<TParameters, TDetails>).

TS AgentTool extends Tool with label, optional prepareArguments, execute, and per-tool executionMode. The Rust port keeps the same shape: a struct-less #[async_trait] AgentTool returning the public Tool schema from rpi_ai. Tools are held behind Arc<dyn AgentTool> so the agent can store + dispatch them without generics.

The execute signature carries an on_update callback (&dyn Fn) for streaming partial results. The loop wraps it with an accepting_updates: Arc<AtomicBool> gate so calls made after execute resolves are no-ops — the late-update suppression invariant (plan §5.3).

Traits§

AgentTool
A tool the agent can call. Mirrors TS AgentTool<TParameters, TDetails>.