// Copyright (c) Microsoft. All rights reserved. using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using Microsoft.Shared.DiagnosticIds; namespace Microsoft.Agents.AI; /// /// Marks a property or method as a skill resource that is automatically discovered by . /// /// /// /// Apply this attribute to properties or methods in an subclass to register /// them as skill resources. /// /// /// To provide a description for the resource, apply /// to the same member. /// /// /// When applied to a property, the property getter is invoked each time the resource is read, /// enabling dynamic (computed) resources. When applied to a method, the method is invoked each time /// the resource is read, also enabling dynamic resources. Methods with an /// parameter support dependency injection. /// /// /// This attribute is compatible with Native AOT when used with . /// Alternatively, override the property and use /// instead. /// /// /// /// /// public class MySkill : AgentClassSkill<MySkill> /// { /// public override AgentSkillFrontmatter Frontmatter { get; } = new("my-skill", "A skill."); /// protected override string Instructions => "Use this skill to do something."; /// /// [AgentSkillResource("reference-data")] /// [Description("Some reference content for the skill.")] /// public string ReferenceData => "Some reference content."; /// } /// /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] [Experimental(DiagnosticIds.Experiments.AgentsAIExperiments)] public sealed class AgentSkillResourceAttribute : Attribute { /// /// Initializes a new instance of the class. /// The resource name defaults to the property or method name. /// public AgentSkillResourceAttribute() { } /// /// Initializes a new instance of the class /// with an explicit resource name. /// /// The resource name used to identify this resource. public AgentSkillResourceAttribute(string name) { this.Name = name; } /// /// Gets the resource name, or to use the member name. /// public string? Name { get; } }