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.
Sourcepub fn with_output_limit(self, limit: ToolOutputLimit) -> Self
pub fn with_output_limit(self, limit: ToolOutputLimit) -> Self
Advertises this tool’s preferred output overflow behaviour.
This is advisory metadata: hosts opt into it by configuring an output truncation strategy that reads tool metadata. Executor-level per-tool overrides still take precedence.
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.