pub struct ToolSpec {
pub name: ToolName,
pub description: String,
pub input_schema: Value,
pub annotations: ToolAnnotations,
pub metadata: MetadataMap,
}Expand description
Declarative specification of a tool’s identity, schema, and behavioural hints.
Every Tool implementation exposes a ToolSpec that the framework uses to
advertise the tool to an LLM, validate inputs, and drive permission checks.
§Example
use agentkit_tools_core::{ToolAnnotations, ToolName, ToolSpec};
use serde_json::json;
let spec = ToolSpec::new(
ToolName::new("grep_search"),
"Search files by regex pattern",
json!({
"type": "object",
"properties": {
"pattern": { "type": "string" },
"path": { "type": "string" }
},
"required": ["pattern"]
}),
)
.with_annotations(ToolAnnotations::read_only());Fields§
§name: ToolNameMachine-readable name used to route tool calls.
description: StringHuman-readable description sent to the LLM so it knows when to use this tool.
input_schema: ValueJSON Schema describing the expected input object.
annotations: ToolAnnotationsAdvisory behavioural hints (read-only, destructive, etc.).
metadata: MetadataMapArbitrary key-value pairs for framework extensions.
Implementations§
Source§impl ToolSpec
impl ToolSpec
Sourcepub fn new(
name: impl Into<ToolName>,
description: impl Into<String>,
input_schema: Value,
) -> Self
pub fn new( name: impl Into<ToolName>, description: impl Into<String>, input_schema: Value, ) -> Self
Builds a tool spec with default annotations and empty metadata.
Sourcepub fn with_annotations(self, annotations: ToolAnnotations) -> Self
pub fn with_annotations(self, annotations: ToolAnnotations) -> Self
Replaces the tool annotations.
Sourcepub fn with_metadata(self, metadata: MetadataMap) -> Self
pub fn with_metadata(self, metadata: MetadataMap) -> Self
Replaces the tool metadata.
Source§impl ToolSpec
impl ToolSpec
Sourcepub fn as_invocable_spec(&self) -> InvocableSpec
pub fn as_invocable_spec(&self) -> InvocableSpec
Converts this spec into an InvocableSpec for use with the
capability layer.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ToolSpec
impl<'de> Deserialize<'de> for ToolSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for ToolSpec
Auto Trait Implementations§
impl Freeze for ToolSpec
impl RefUnwindSafe for ToolSpec
impl Send for ToolSpec
impl Sync for ToolSpec
impl Unpin for ToolSpec
impl UnsafeUnpin for ToolSpec
impl UnwindSafe for ToolSpec
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
Mutably borrows from an owned value. Read more