Table of Contents

Class AgentExtensions

Namespace
Microsoft.AutoGen.Core
Assembly
Microsoft.AutoGen.Core.dll

Provides extension methods for the Agent class.

public static class AgentExtensions
Inheritance
AgentExtensions
Inherited Members

Methods

ExtractActivity(Agent, string, MapField<string, CloudEventAttributeValue>)

public static Activity? ExtractActivity(this Agent agent, string activityName, MapField<string, CloudEvent.Types.CloudEventAttributeValue> metadata)

Parameters

agent Agent
activityName string
metadata MapField<string, CloudEvent.Types.CloudEventAttributeValue>

Returns

Activity

ExtractActivity(Agent, string, IDictionary<string, string>)

Extracts an Activity from the given agent and metadata.

public static Activity? ExtractActivity(this Agent agent, string activityName, IDictionary<string, string> metadata)

Parameters

agent Agent

The agent from which to extract the activity.

activityName string

The name of the activity.

metadata IDictionary<string, string>

The metadata containing trace information.

Returns

Activity

The extracted Activity or null if extraction fails.

InvokeWithActivityAsync<TState>(Agent, Func<TState, CancellationToken, Task>, TState, Activity?, string, CancellationToken)

Invokes a function asynchronously within the context of an Activity.

public static Task InvokeWithActivityAsync<TState>(this Agent agent, Func<TState, CancellationToken, Task> func, TState state, Activity? activity, string methodName, CancellationToken cancellationToken = default)

Parameters

agent Agent

The agent invoking the function.

func Func<TState, CancellationToken, Task>

The function to invoke.

state TState

The state parameter to pass to the function.

activity Activity

The activity within which to invoke the function.

methodName string

The name of the method being invoked.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task

A task representing the asynchronous operation.

Type Parameters

TState

The type of the state parameter.