Method InvokeAsync
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
- argumentsstring
- A UTF-8 JSON string representing an object that should validate against InputSchema. 
- cancellationTokenCancellationToken
- Cancellation token propagated from the calling agent run. 
Returns
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 resultRemarks
Error handling guidance:
- Throw ArgumentException for schema/validation errors.
- Throw HttpRequestException for network/API failures.
- Respect OperationCanceledException if cancellationTokenis canceled.