Table of Contents

Class ToolCall

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

Represents a tool invocation request emitted by a language model.

public sealed class ToolCall
Inheritance
ToolCall
Inherited Members

Examples

Example: Processing tool calls from agent execution

using LMKit.Agents;
using LMKit.Agents.Tools;

var result = await agent.RunAsync("What's the weather in Paris?");

// Inspect which tools were called during execution
if (result.ToolCalls != null && result.ToolCalls.Count > 0)
{
    Console.WriteLine($"Agent made {result.ToolCalls.Count} tool call(s):");

    foreach (ToolCall call in result.ToolCalls)
    {
        Console.WriteLine($"  Tool: {call.Name}");
        Console.WriteLine($"  ID: {call.Id}");
        Console.WriteLine($"  Arguments: {call.ArgumentsJson}");
        Console.WriteLine();
    }
}

Remarks

When a language model decides to use a tool, it emits a tool call containing the tool's name and the arguments to pass. The ToolCall class captures this information so the agent runtime can locate the tool in the registry and invoke it.

Lifecycle:

  1. Model generates a tool call with name and arguments
  2. Runtime parses the output into a ToolCall instance
  3. Runtime looks up the tool by Name in the registry
  4. Runtime invokes the tool with ArgumentsJson
  5. Tool result is associated back using Id for correlation

Correlation:
The Id property enables correlation between tool calls and their results, which is important when multiple tools are called in a single turn. Always include the same Id in the corresponding ToolCallResult.

Properties

ArgumentsJson

Gets the JSON arguments to pass to the tool.

Id

Gets the unique identifier for this tool call within a turn.

Name

Gets the name of the tool to invoke.