Skip to content

IterativeLoopResult

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework.Iterative

IterativeLoopResult Class

The result of running an IIterativeAgentLoop to completion, including per-iteration records, aggregate diagnostics, and the final model response.

public sealed record IterativeLoopResult : System.IEquatable<NexusLabs.Needlr.AgentFramework.Iterative.IterativeLoopResult>

Inheritance System.Object 🡒 IterativeLoopResult

Implements System.IEquatable<IterativeLoopResult>

Remarks

Iterations provides a complete trace of what happened in each iteration — which tools were called, what text was produced, and how many tokens were consumed. This is the primary diagnostic surface for understanding loop behavior and optimizing prompt factories.

Constructors

IterativeLoopResult(IReadOnlyList<IterationRecord>, string, IAgentRunDiagnostics, bool, string, TerminationReason, IterativeLoopConfiguration) Constructor

The result of running an IIterativeAgentLoop to completion, including per-iteration records, aggregate diagnostics, and the final model response.

public IterativeLoopResult(System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.AgentFramework.Iterative.IterationRecord> Iterations, string? FinalResponse, NexusLabs.Needlr.AgentFramework.Diagnostics.IAgentRunDiagnostics? Diagnostics, bool Succeeded, string? ErrorMessage, NexusLabs.Needlr.AgentFramework.Iterative.TerminationReason Termination, NexusLabs.Needlr.AgentFramework.Iterative.IterativeLoopConfiguration Configuration);

Parameters

Iterations System.Collections.Generic.IReadOnlyList<IterationRecord>

Per-iteration records in execution order. Always contains at least one entry.

FinalResponse System.String

The last text response produced by the model, or null if the loop was terminated by MaxIterations, IsComplete, or cancellation before the model produced a text response.

Diagnostics IAgentRunDiagnostics

Aggregate diagnostics for the entire loop run, including total token usage, all chat completions, and all tool calls. null if diagnostics were not enabled via UsingDiagnostics().

Succeeded System.Boolean

Whether the loop completed without errors.

ErrorMessage System.String

The error message if the loop failed; null on success. Populated when the prompt factory throws, the loop is cancelled, or an unrecoverable LLM error occurs.

Termination TerminationReason

Why the loop stopped. Use this instead of inspecting Succeeded and ErrorMessage separately — it provides a single discriminator for all termination paths.

Configuration IterativeLoopConfiguration

Snapshot of the resolved configuration used for this run. Allows consumers to inspect mode, limits, and budget settings after execution without referencing the original IterativeLoopOptions.

Remarks

Iterations provides a complete trace of what happened in each iteration — which tools were called, what text was produced, and how many tokens were consumed. This is the primary diagnostic surface for understanding loop behavior and optimizing prompt factories.

Properties

IterativeLoopResult.Configuration Property

Snapshot of the resolved configuration used for this run. Allows consumers to inspect mode, limits, and budget settings after execution without referencing the original IterativeLoopOptions.

public NexusLabs.Needlr.AgentFramework.Iterative.IterativeLoopConfiguration Configuration { get; init; }

Property Value

IterativeLoopConfiguration

IterativeLoopResult.Diagnostics Property

Aggregate diagnostics for the entire loop run, including total token usage, all chat completions, and all tool calls. null if diagnostics were not enabled via UsingDiagnostics().

public NexusLabs.Needlr.AgentFramework.Diagnostics.IAgentRunDiagnostics? Diagnostics { get; init; }

Property Value

IAgentRunDiagnostics

IterativeLoopResult.ErrorMessage Property

The error message if the loop failed; null on success. Populated when the prompt factory throws, the loop is cancelled, or an unrecoverable LLM error occurs.

public string? ErrorMessage { get; init; }

Property Value

System.String

IterativeLoopResult.FinalResponse Property

The last text response produced by the model, or null if the loop was terminated by MaxIterations, IsComplete, or cancellation before the model produced a text response.

public string? FinalResponse { get; init; }

Property Value

System.String

IterativeLoopResult.Iterations Property

Per-iteration records in execution order. Always contains at least one entry.

public System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.AgentFramework.Iterative.IterationRecord> Iterations { get; init; }

Property Value

System.Collections.Generic.IReadOnlyList<IterationRecord>

IterativeLoopResult.Succeeded Property

Whether the loop completed without errors.

public bool Succeeded { get; init; }

Property Value

System.Boolean

IterativeLoopResult.Termination Property

Why the loop stopped. Use this instead of inspecting Succeeded and ErrorMessage separately — it provides a single discriminator for all termination paths.

public NexusLabs.Needlr.AgentFramework.Iterative.TerminationReason Termination { get; init; }

Property Value

TerminationReason