AgentExtensionAttribute<TExtension> Class

Definition

Base attribute for automatically generating an extension property on an AgentApplication subclass.

[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=false)]
public class AgentExtensionAttribute<TExtension> : Attribute where TExtension : IAgentExtension
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=false)>]
type AgentExtensionAttribute<'Extension (requires 'Extension :> IAgentExtension)> = class
    inherit Attribute
Public Class AgentExtensionAttribute(Of TExtension)
Inherits Attribute

Type Parameters

TExtension

The IAgentExtension type to expose as a generated property.

Inheritance
AgentExtensionAttribute<TExtension>
Attributes

Remarks

Subclass this attribute to create a named shortcut for a specific extension type. The decorated class must be declared as partial. A source generator creates a companion partial class that exposes a TExtension property whose name is derived by stripping the AgentExtension or Extension suffix from the type name (e.g. TeamsAgentExtensionTeamsExtension). The extension is eagerly initialized and registered during construction via the generated ConfigureExtensions override, ensuring extension handlers are active before the first turn is processed.

Multiple different extension attributes may be applied to the same class.

// Define a custom extension attribute:
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class MyExtensionAttribute : AgentExtensionAttribute<MyAgentExtension> { }

// Use it on an agent:
[MyExtension]
public partial class MyAgent(AgentApplicationOptions options) : AgentApplication(options)
{
    // Generated: public MyAgentExtension My { get; }
}

Constructors

Name Description
AgentExtensionAttribute<TExtension>()

Applies to