Table of Contents

Method Failure

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

Failure(Exception, string, IReadOnlyList<ToolCallResult>, TimeSpan, int)

Creates a failed execution result.

public static AgentExecutionResult Failure(Exception error, string partialContent = null, IReadOnlyList<ToolCallResult> toolCalls = null, TimeSpan duration = default, int inferenceCount = 0)

Parameters

error Exception

The exception that caused the failure.

partialContent string

Any partial content generated before failure.

toolCalls IReadOnlyList<ToolCallResult>

Any tool calls made before failure.

duration TimeSpan

The execution duration until failure.

inferenceCount int

The number of inference calls made.

Returns

AgentExecutionResult

A new failed AgentExecutionResult.

Examples

Creating a failure result (for custom executors):

using LMKit.Agents;

try
{
    // Some operation that might fail
}
catch (Exception ex)
{
    var result = AgentExecutionResult.Failure(
        error: ex,
        partialContent: "Processing started but...",
        duration: TimeSpan.FromMilliseconds(50)
    );

    Console.WriteLine(result.IsFailed);     // True
    Console.WriteLine(result.Error.Message);
}