AgentSkillScriptAttribute Class

Definition

Marks a method as a skill script that is automatically discovered by AgentClassSkill<TSelf>.

[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)]
public sealed class AgentSkillScriptAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)>]
type AgentSkillScriptAttribute = class
    inherit Attribute
Public NotInheritable Class AgentSkillScriptAttribute
Inherits Attribute
Inheritance
AgentSkillScriptAttribute
Attributes

Examples

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.";

    [AgentSkillScript("do-something")]
    [Description("Converts the input to upper case.")]
    private static string DoSomething(string input) => input.ToUpperInvariant();
}

Remarks

Apply this attribute to methods in an AgentClassSkill<TSelf> subclass to register them as skill scripts. The method's parameters and return type are automatically marshaled via AIFunctionFactory.

To provide a description for the script, apply DescriptionAttribute to the same method.

Methods can be instance or static, and may have any visibility (public, private, etc.). Methods with an IServiceProvider parameter support dependency injection.

This attribute is compatible with Native AOT when used with AgentClassSkill<TSelf>. Alternatively, override Scripts and use CreateScript(String, Delegate, String, JsonSerializerOptions) instead.

Constructors

Name Description
AgentSkillScriptAttribute()

Initializes a new instance of the AgentSkillScriptAttribute class. The script name defaults to the method name.

AgentSkillScriptAttribute(String)

Initializes a new instance of the AgentSkillScriptAttribute class with an explicit script name.

Properties

Name Description
Name

Gets the script name, or null to use the method name.

Applies to