Share via


AgentRunMode.AllowBackgroundWhen Method

Definition

The agent run mode is decided by the supplied runInBackground delegate. The delegate receives an A2ARunDecisionContext with the incoming message and returns a boolean specifying whether to run the agent in background mode. true indicates that the agent should run in background mode and return an AgentTask if the agent supports background mode; otherwise, it returns an AgentMessage if the mode is not supported. false indicates that the agent should run in non-background mode and return an AgentMessage.

public static Microsoft.Agents.AI.Hosting.A2A.AgentRunMode AllowBackgroundWhen(Func<Microsoft.Agents.AI.Hosting.A2A.A2ARunDecisionContext,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<bool>> runInBackground);
static member AllowBackgroundWhen : Func<Microsoft.Agents.AI.Hosting.A2A.A2ARunDecisionContext, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<bool>> -> Microsoft.Agents.AI.Hosting.A2A.AgentRunMode
Public Shared Function AllowBackgroundWhen (runInBackground As Func(Of A2ARunDecisionContext, CancellationToken, ValueTask(Of Boolean))) As AgentRunMode

Parameters

runInBackground
Func<A2ARunDecisionContext,CancellationToken,ValueTask<Boolean>>

An async delegate that decides whether the response should be wrapped in an AgentTask.

Returns

Applies to