#[non_exhaustive]pub struct ToolDefinition {
pub name: String,
pub description: String,
pub parameter_schema: Value,
pub effect: ToolEffect,
/* private fields */
}Expand description
Describes a custom tool that can be registered with an agent.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringUnique tool name (e.g. "flash_device").
description: StringHuman-readable description shown to the model.
parameter_schema: ValueJSON Schema describing the tool’s parameters.
effect: ToolEffectExecution effect classification of the tool.
Implementations§
Source§impl ToolDefinition
impl ToolDefinition
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
parameter_schema: Value,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, parameter_schema: Value, ) -> Self
Construct a ToolDefinition with default ToolEffect::Mutating.
Sourcepub fn with_effect(
name: impl Into<String>,
description: impl Into<String>,
parameter_schema: Value,
effect: ToolEffect,
) -> Self
pub fn with_effect( name: impl Into<String>, description: impl Into<String>, parameter_schema: Value, effect: ToolEffect, ) -> Self
Construct a ToolDefinition with an explicit ToolEffect.
Sourcepub fn set_parameter_schema(&mut self, parameter_schema: Value)
pub fn set_parameter_schema(&mut self, parameter_schema: Value)
Update parameter_schema and invalidate any cached JSON serialization.
Sourcepub fn parameter_schema_mut(&mut self) -> &mut Value
pub fn parameter_schema_mut(&mut self) -> &mut Value
Borrow parameter_schema mutably and invalidate any cached JSON serialization.
Sourcepub fn parameter_schema_json(&self) -> &str
pub fn parameter_schema_json(&self) -> &str
Return the pre-serialized JSON schema string (&str), lazily derived
from parameter_schema.
Sourcepub fn parameter_schema_json_arc(&self) -> &Arc<str> ⓘ
pub fn parameter_schema_json_arc(&self) -> &Arc<str> ⓘ
Return the pre-serialized JSON schema string (&Arc<str>), lazily derived
from parameter_schema.
Sourcepub const fn is_idempotent(&self) -> bool
pub const fn is_idempotent(&self) -> bool
Whether repeated invocations with identical arguments are side-effect free / idempotent.
Preserved for backward compatibility.