ToolCompletionCheckMode
NexusLabs.Needlr.AgentFramework¶
NexusLabs.Needlr.AgentFramework.Iterative¶
ToolCompletionCheckMode Enum¶
Controls when the IsComplete predicate is evaluated relative to tool call execution within an iteration.
Fields¶
None 0
No additional IsComplete checks beyond the standard between-iteration check. This is the default and preserves backward-compatible behavior.
AfterToolRounds 1
Check IsComplete after each round's batch
of tool calls completes (i.e., after ExecuteToolCallsAsync returns).
If the predicate returns true, the loop exits immediately
without making the next ChatCompletion call, saving the input token
cost of the wasted round-trip.
Remarks¶
All tool calls requested by the model in a single round are still executed.
Only the subsequent ChatCompletion call is avoided.
AfterEachToolCall 2
Check IsComplete after each individual
tool call completes within a round. If the predicate returns
true, remaining tool calls in the batch are skipped AND
the next ChatCompletion call is avoided.
Remarks¶
This is the most aggressive early-exit mode. It saves both tool execution
cost (for skipped tool calls) and ChatCompletion input token cost.
Remarks¶
By default (None), IsComplete
is checked only between iterations — after the iteration's round loop finishes
and the IterationRecord is built. This means that even when a tool
call satisfies the completion condition mid-iteration, the loop makes one more
ChatCompletion API call before noticing.
The AfterToolRounds and AfterEachToolCall modes add earlier check points within an iteration to enable cost-saving early exit.