T

Struct T 

Source
pub struct T;
Expand description

The T namespace — static factory methods for tool composition.

Implementations§

Source§

impl T

Source

pub fn function(f: Arc<dyn ToolFunction>) -> ToolComposite

Register a function tool.

Add Google Search built-in tool.

Source

pub fn url_context() -> ToolComposite

Add URL context built-in tool.

Source

pub fn code_execution() -> ToolComposite

Add code execution built-in tool.

Source

pub fn simple<F, Fut>( name: impl Into<String>, description: impl Into<String>, f: F, ) -> ToolComposite
where F: Fn(Value) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Value, ToolError>> + Send + 'static,

Create a simple tool from a name, description, and async closure.

Source

pub fn fn_tool<F, Fut>( name: impl Into<String>, description: impl Into<String>, f: F, ) -> ToolComposite
where F: Fn(Value) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Value, ToolError>> + Send + 'static,

Alias for simple — matches upstream Python T.fn().

Named fn_tool because fn is a reserved keyword in Rust.

Source

pub fn confirm(tool: ToolComposite, message: &str) -> ToolComposite

Require user confirmation before each function tool in the composite runs.

The confirmation flag is recorded on the tool’s ToolPolicy and surfaced to the runtime via PolicyTool::requires_confirmation — it is never silently dropped. The message becomes the confirmation hint. Built-in and placeholder entries are left unchanged.

Source

pub fn timeout(tool: ToolComposite, duration: Duration) -> ToolComposite

Bound each function tool in the composite by a timeout.

At dispatch the tool’s future is raced against the duration; on elapse the call returns ToolError::Timeout. Built-in and placeholder entries are left unchanged.

Source

pub fn cached(tool: ToolComposite) -> ToolComposite

Memoize each function tool’s successful results.

Results are cached by (tool name, canonical-JSON args); repeat calls with identical arguments return the cached value without re-invoking the tool. Errors are not cached. Built-in/placeholder entries are left unchanged.

Source

pub fn toolset(tools: Vec<Arc<dyn ToolFunction>>) -> ToolComposite

Combine multiple tool functions into a single composite.

Source

pub fn agent( name: impl Into<String>, description: impl Into<String>, agent: impl TextAgent + 'static, ) -> ToolComposite

Wrap a TextAgent as a tool (shorthand for creating an agent tool entry).

When invoked, the agent runs via BaseLlm::generate() and returns its text output as the tool result. State is shared with the parent session.

Source

pub fn mcp(params: impl Into<String>) -> ToolComposite

Create an MCP (Model Context Protocol) toolset entry.

params is the connection string (e.g. a URL or command) used to establish the MCP session at runtime.

Source

pub fn mock( name: impl Into<String>, description: impl Into<String>, response: Value, ) -> ToolComposite

Create a mock tool that returns a fixed response.

Useful for testing and prototyping without real tool implementations.

Source

pub fn schema(name: impl Into<String>, schema: Value) -> ToolComposite

Create a schema-defined tool (placeholder/marker).

The tool’s parameters are defined by the given JSON Schema value.

Source

pub fn transform<F, Fut>(tool: ToolComposite, f: F) -> ToolComposite
where F: Fn(Value) -> Fut + Send + Sync + 'static, Fut: Future<Output = Value> + Send + 'static,

Wrap each tool entry in a composite with a result transformer.

The transformer function is applied to the tool’s output value before it is returned to the model.

Auto Trait Implementations§

§

impl Freeze for T

§

impl RefUnwindSafe for T

§

impl Send for T

§

impl Sync for T

§

impl Unpin for T

§

impl UnwindSafe for T

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,