TerminationReason
NexusLabs.Needlr.AgentFramework¶
NexusLabs.Needlr.AgentFramework.Iterative¶
TerminationReason Enum¶
Describes why an IIterativeAgentLoop run terminated.
Fields¶
Completed 0
The IsComplete predicate returned true after an iteration — the agent achieved its goal.
NaturalCompletion 1
The model produced a text response without requesting tool calls, signaling natural completion of the task.
MaxIterationsReached 2
The loop exhausted MaxIterations without the IsComplete predicate returning true.
MaxToolCallsReached 3
The cumulative tool call count across all iterations exceeded MaxTotalToolCalls.
BudgetPressure 4
The ITokenBudgetTracker reported usage above the budget pressure threshold, and the loop ran one final finalization iteration before terminating.
Cancelled 5
The loop was cancelled via System.Threading.CancellationToken.
Error 6
An unrecoverable error occurred (prompt factory failure, LLM exception, etc.).
StallDetected 7
The loop detected that consecutive iterations produced nearly identical token usage, indicating the LLM is repeating the same work without making progress. Controlled by StallDetection.
CompletedEarlyAfterToolCall 8
The IsComplete predicate returned
true after a tool call completed within an iteration,
rather than at the standard between-iteration check point. This is a
\<strong>success\</strong> termination — the agent achieved its goal and
the loop exited early to avoid a wasted ChatCompletion call.
Remarks¶
Only fires when CheckCompletionAfterToolCalls is set to AfterToolRounds or AfterEachToolCall.