Class ToolCallResult
Represents the outcome of executing a tool invocation.
public sealed class ToolCallResult
- Inheritance
-
ToolCallResult
- Inherited Members
Examples
Example: Examining tool call results from agent execution
using LMKit.Agents;
using LMKit.Agents.Tools;
var result = await agent.RunAsync("Search for recent AI news");
// Check the execution trace for tool results
if (result.ReasoningTrace != null)
{
foreach (var step in result.ReasoningTrace)
{
if (step.ToolResult != null)
{
ToolCallResult toolResult = step.ToolResult;
Console.WriteLine($"Tool: {toolResult.ToolName}");
Console.WriteLine($"Status: {toolResult.Type}");
if (toolResult.Type == ToolCallResultType.Success)
{
Console.WriteLine($"Result: {toolResult.ResultJson}");
}
else if (toolResult.Type == ToolCallResultType.Error)
{
Console.WriteLine($"Error: {toolResult.ResultJson}");
}
}
}
}
Remarks
ToolCallResult captures the result of invoking a tool, including the JSON payload returned by the tool, the outcome classification, and correlation information linking back to the original ToolCall.
Lifecycle:
- Runtime invokes a tool based on a ToolCall
- Tool returns JSON result or throws an exception
- Runtime creates a ToolCallResult with appropriate Type
- Result is sent back to the model with the correlated ToolCallId
- Model uses the result to formulate its final response
Immutability:
This class is immutable after construction, making it thread-safe for concurrent readers.
Properties
- ResultJson
Gets the JSON payload returned by the tool or describing the outcome.
- ToolCallId
Gets the identifier that correlates this result with its originating tool call.
- ToolName
Gets the name of the tool that was executed.
- Type
Gets the classification of the tool invocation outcome.