HandoffWorkflowBuilderCore<TBuilder>.WithTerminationCondition Method

Definition

Overloads

Name Description
WithTerminationCondition(Func<IReadOnlyList<ChatMessage>,Boolean>)

Sets a synchronous termination condition for the handoff workflow.

WithTerminationCondition(Func<IReadOnlyList<ChatMessage>,ValueTask<Boolean>>)

Sets an asynchronous termination condition for the handoff workflow.

WithTerminationCondition(Func<IReadOnlyList<ChatMessage>,Boolean>)

Sets a synchronous termination condition for the handoff workflow.

public TBuilder WithTerminationCondition(Func<System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage>,bool> terminationCondition);
member this.WithTerminationCondition : Func<System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage>, bool> -> 'Builder
Public Function WithTerminationCondition (terminationCondition As Func(Of IReadOnlyList(Of ChatMessage), Boolean)) As TBuilder

Parameters

terminationCondition
Func<IReadOnlyList<ChatMessage>,Boolean>

A predicate that receives the current conversation and returns true if the workflow should terminate (preventing further autonomous continuation). The synchronous predicate is wrapped and forwarded to the async overload.

Returns

TBuilder

The updated builder instance.

Remarks

The termination condition is evaluated after the agent produces a response that does not request a handoff. When it returns true, the workflow ends without invoking another autonomous continuation.

Applies to

WithTerminationCondition(Func<IReadOnlyList<ChatMessage>,ValueTask<Boolean>>)

Sets an asynchronous termination condition for the handoff workflow.

public TBuilder WithTerminationCondition(Func<System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage>,System.Threading.Tasks.ValueTask<bool>> terminationCondition);
member this.WithTerminationCondition : Func<System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage>, System.Threading.Tasks.ValueTask<bool>> -> 'Builder
Public Function WithTerminationCondition (terminationCondition As Func(Of IReadOnlyList(Of ChatMessage), ValueTask(Of Boolean))) As TBuilder

Parameters

terminationCondition
Func<IReadOnlyList<ChatMessage>,ValueTask<Boolean>>

A predicate that receives the current conversation and asynchronously returns true if the workflow should terminate (preventing further autonomous continuation).

Returns

TBuilder

The updated builder instance.

Remarks

The termination condition is evaluated after the agent produces a response that does not request a handoff. When it returns true, the workflow ends without invoking another autonomous continuation.

Applies to