Skip to content

TerminationContext

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework

TerminationContext Class

Provides context to an IWorkflowTerminationCondition when evaluating whether a workflow should stop after an agent's response.

public sealed class TerminationContext

Inheritance System.Object 🡒 TerminationContext

Properties

TerminationContext.AgentId Property

Gets the executor ID of the agent that produced this response.

public string AgentId { get; init; }

Property Value

System.String

TerminationContext.ConversationHistory Property

Gets the accumulated conversation history up to and including this turn. Each entry corresponds to one completed agent response.

public System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage> ConversationHistory { get; init; }

Property Value

System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage>

TerminationContext.LastMessage Property

Gets the last Microsoft.Extensions.AI.ChatMessage emitted by the agent for this turn (preserving full content including function calls, role, and metadata), or null if the agent produced no message. Use the .Text property on the message for a flat text view.

public Microsoft.Extensions.AI.ChatMessage? LastMessage { get; init; }

Property Value

Microsoft.Extensions.AI.ChatMessage

TerminationContext.ToolCallNames Property

Gets the names of tools/functions called by the agent during this turn. Extracted from Microsoft.Extensions.AI.FunctionCallContent entries in the last message's Microsoft.Extensions.AI.ChatMessage.Contents. Empty if no tool calls were made.

public System.Collections.Generic.IReadOnlyList<string> ToolCallNames { get; init; }

Property Value

System.Collections.Generic.IReadOnlyList<System.String>

TerminationContext.TurnCount Property

Gets the number of agent turns completed so far (1-based).

public int TurnCount { get; init; }

Property Value

System.Int32

TerminationContext.Usage Property

Gets token usage for this turn, if reported by the model. May be null when the model does not return usage metadata.

public Microsoft.Extensions.AI.UsageDetails? Usage { get; init; }

Property Value

Microsoft.Extensions.AI.UsageDetails