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>, ChatResponse, 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, Microsoft.Extensions.AI.ChatResponse? 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 Microsoft.Extensions.AI.ChatResponse
The last Microsoft.Extensions.AI.ChatResponse produced by the model (preserving full message
content, role, usage, and metadata), or null if the loop was
terminated by MaxIterations,
IsComplete, or cancellation before the model
produced a response. Call .Text for a flat text view when evaluating.
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¶
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().
Property Value¶
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.
Property Value¶
IterativeLoopResult.FinalResponse Property¶
The last Microsoft.Extensions.AI.ChatResponse produced by the model (preserving full message
content, role, usage, and metadata), or null if the loop was
terminated by MaxIterations,
IsComplete, or cancellation before the model
produced a response. Call .Text for a flat text view when evaluating.
Property Value¶
Microsoft.Extensions.AI.ChatResponse
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.
Property Value¶
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.