pub struct FunctionTool<Input, Output, Handler> { /* private fields */ }Expand description
A typed asynchronous Rust function exposed through the canonical Tool boundary.
Implementations§
Source§impl<Input, Output, Handler> FunctionTool<Input, Output, Handler>where
Input: JsonSchema,
Output: JsonSchema,
impl<Input, Output, Handler> FunctionTool<Input, Output, Handler>where
Input: JsonSchema,
Output: JsonSchema,
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
handler: Handler,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, handler: Handler, ) -> Self
Creates a typed Tool with generated input and output JSON Schemas.
The default effect is EffectClass::Pure and the default risk is
RiskLevel::Low. Callers must explicitly override these values for
functions that read or modify external state.
Source§impl<Input, Handler> FunctionTool<Input, ToolOutput, Handler>where
Input: JsonSchema,
impl<Input, Handler> FunctionTool<Input, ToolOutput, Handler>where
Input: JsonSchema,
Sourcepub fn new_rich(
name: impl Into<String>,
description: impl Into<String>,
handler: Handler,
) -> Self
pub fn new_rich( name: impl Into<String>, description: impl Into<String>, handler: Handler, ) -> Self
Creates a typed Tool whose handler returns canonical rich content.
Unlike Self::new, this constructor preserves the returned
ToolOutput instead of serializing it into JSON text. The default
output schema is permissive because rich presentation content and
optional structured content are validated by the canonical Tool
boundary rather than one generated Rust output type.
Source§impl<Input, Output, Handler> FunctionTool<Input, Output, Handler>
impl<Input, Output, Handler> FunctionTool<Input, Output, Handler>
Sourcepub const fn capability_id(self, id: CapabilityId) -> Self
pub const fn capability_id(self, id: CapabilityId) -> Self
Replaces the stable capability identity.
Sourcepub fn version(self, version: impl Into<String>) -> Self
pub fn version(self, version: impl Into<String>) -> Self
Sets the semantic Tool contract version.
Sourcepub const fn effect(self, effect: EffectClass) -> Self
pub const fn effect(self, effect: EffectClass) -> Self
Declares external-effect behavior.
Sourcepub fn metadata(self, key: impl Into<String>, value: Value) -> Self
pub fn metadata(self, key: impl Into<String>, value: Value) -> Self
Adds host-only namespaced metadata.
Sourcepub fn output_schema(self, schema: Value) -> Self
pub fn output_schema(self, schema: Value) -> Self
Replaces the successful output schema.
This is primarily useful for rich Tools that attach typed
structured_content alongside media. The registry compiles and
enforces the schema before exposing a successful result to an Agent.