pub struct ChainedInvoker { /* private fields */ }Expand description
Tool invoker that dispatches calls to a registered set of Tool
impls by name. Validates args against each tool’s json_schema
before invocation, and enforces a per-invocation timeout.
Implementations§
Source§impl ChainedInvoker
impl ChainedInvoker
Sourcepub fn new() -> ChainedInvoker
pub fn new() -> ChainedInvoker
Build an empty invoker with a 30-second default timeout.
Sourcepub fn with_default_timeout(self, t: Duration) -> ChainedInvoker
pub fn with_default_timeout(self, t: Duration) -> ChainedInvoker
Override the default per-tool timeout. Default: 30 seconds.
Sourcepub fn with_per_tool_timeout(
self,
tool_name: impl Into<String>,
dur: Duration,
) -> ChainedInvoker
pub fn with_per_tool_timeout( self, tool_name: impl Into<String>, dur: Duration, ) -> ChainedInvoker
Override the timeout for a specific tool by name. Repeated calls
for the same tool_name keep the latest. The override applies
regardless of registration order — the tool need not be added
before the override.
Sourcepub fn add_tool(&mut self, tool: Arc<dyn Tool>) -> Result<(), InvokerError>
pub fn add_tool(&mut self, tool: Arc<dyn Tool>) -> Result<(), InvokerError>
Register a tool by mutating the invoker in place. Useful when
building from a dynamic source (e.g. iterating a Vec). Returns
InvokerError::DuplicateTool when a tool with the same name is
already registered.
Sourcepub fn with_tool(
self,
tool: Arc<dyn Tool>,
) -> Result<ChainedInvoker, InvokerError>
pub fn with_tool( self, tool: Arc<dyn Tool>, ) -> Result<ChainedInvoker, InvokerError>
Register a tool, consuming and returning self. Convenient for
inline chaining: ChainedInvoker::new().with_tool(a)?.with_tool(b)?.
Delegates to Self::add_tool.
Sourcepub fn with_tool_owned<T>(self, tool: T) -> Result<ChainedInvoker, InvokerError>where
T: Tool + 'static,
pub fn with_tool_owned<T>(self, tool: T) -> Result<ChainedInvoker, InvokerError>where
T: Tool + 'static,
Returns InvokerError::DuplicateTool when a tool with the
same name is already registered.
Trait Implementations§
Source§impl Debug for ChainedInvoker
impl Debug for ChainedInvoker
Source§impl Default for ChainedInvoker
impl Default for ChainedInvoker
Source§fn default() -> ChainedInvoker
fn default() -> ChainedInvoker
Source§impl ToolInvoker for ChainedInvoker
impl ToolInvoker for ChainedInvoker
Source§fn invoke<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: Value,
ctx: ToolCtx,
) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChainedInvoker: 'async_trait,
fn invoke<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: Value,
ctx: ToolCtx,
) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChainedInvoker: 'async_trait,
name with args against the supplied context.Source§fn tool_redacts_audit(&self, name: &str) -> bool
fn tool_redacts_audit(&self, name: &str) -> bool
Tool::redacts_audit across the invoker boundary
(dispatch holds a ToolInvoker, not the concrete Tool).
Per-name granularity so one invoker can mix PII-handling and
non-PII tools. Default false (raw).Auto Trait Implementations§
impl !RefUnwindSafe for ChainedInvoker
impl !UnwindSafe for ChainedInvoker
impl Freeze for ChainedInvoker
impl Send for ChainedInvoker
impl Sync for ChainedInvoker
impl Unpin for ChainedInvoker
impl UnsafeUnpin for ChainedInvoker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().