Table of Contents

Method InvokeAsync

Namespace
LMKit.Agents.Tools
Assembly
LM-Kit.NET.dll

InvokeAsync(string, CancellationToken)

Executes the tool with the provided JSON argument payload and returns a JSON payload result.

Task<string> InvokeAsync(string arguments, CancellationToken cancellationToken = default)

Parameters

arguments string

A UTF-8 JSON string representing an object that should validate against InputSchema.

cancellationToken CancellationToken

Cancellation token propagated from the calling agent run.

Returns

Task<string>

A JSON string suitable to return to the LLM as the tool result.

Examples

var tool = new WeatherTool();
var args = new { location = "Toulouse, FR", includeForecast = true };
string input = JsonSerializer.Serialize(args);
string output = await tool.InvokeAsync(input, ct);
// feed 'output' back to the LLM as the tool result

Remarks

Error handling guidance:

Returned JSON should be compact and structured; avoid large blobs unless necessary.