Class ToolDefinition
- Namespace
- Emissary
- Assembly
- Emissary.dll
A fully materialized tool: wire name, description, compile-time JSON Schema, and a reflection-free dispatcher. Instances are normally produced by the Emissary source generator from ClaudeToolAttribute-annotated methods, but can be built by hand.
public sealed class ToolDefinition
- Inheritance
-
ToolDefinition
- Inherited Members
Constructors
ToolDefinition(string, string, string, Func<JsonElement, CancellationToken, ValueTask<string>>, string?, bool, bool, Func<JsonElement, CancellationToken, ValueTask<string>>?, int?)
Creates a tool definition.
public ToolDefinition(string name, string description, string inputSchemaJson, Func<JsonElement, CancellationToken, ValueTask<string>> handler, string? requiredPolicy = null, bool untrusted = false, bool privileged = false, Func<JsonElement, CancellationToken, ValueTask<string>>? compensation = null, int? maxResultLength = null)
Parameters
namestringThe wire name of the tool.
descriptionstringThe description shown to the model.
inputSchemaJsonstringThe JSON Schema for the tool input, as a JSON string.
handlerFunc<JsonElement, CancellationToken, ValueTask<string>>The dispatcher invoked with the tool-use input.
requiredPolicystringPolicy an IToolAuthorizer must grant, or null.
untrustedboolWhether the tool's output taints the run (see Untrusted).
privilegedboolWhether the tool is blocked in tainted runs (see Privileged).
compensationFunc<JsonElement, CancellationToken, ValueTask<string>>Handler that undoes this tool's effect given the original input, or null.
maxResultLengthint?Caps how much of the tool's output reaches the model; null for no cap.
Exceptions
- ArgumentNullException
A required argument is null.
Properties
Compensation
Undoes this tool's effect given the original input, or null.
public Func<JsonElement, CancellationToken, ValueTask<string>>? Compensation { get; }
Property Value
Description
The description shown to the model.
public string Description { get; }
Property Value
Handler
The dispatcher invoked with the tool-use input.
public Func<JsonElement, CancellationToken, ValueTask<string>> Handler { get; }
Property Value
InputSchemaJson
The JSON Schema for the tool input, as a JSON string.
public string InputSchemaJson { get; }
Property Value
MaxResultLength
Caps how much of this tool's output reaches the model, guarding the context window and token budget against a tool that returns far more than expected. null means no cap.
public int? MaxResultLength { get; }
Property Value
- int?
Name
The wire name of the tool.
public string Name { get; }
Property Value
Privileged
Whether the tool is blocked once the run is tainted.
public bool Privileged { get; }
Property Value
RequiredPolicy
The policy an IToolAuthorizer must grant, or null for none.
public string? RequiredPolicy { get; }
Property Value
Untrusted
Whether a successful call taints the run with untrusted content.
public bool Untrusted { get; }
Property Value
Methods
InvokeAsync(JsonElement, CancellationToken)
Invokes the tool with the given tool-use input.
public ValueTask<string> InvokeAsync(JsonElement input, CancellationToken cancellationToken = default)
Parameters
inputJsonElementThe tool-use input object.
cancellationTokenCancellationTokenCancels the tool execution.