AgentInlineSkill.AddScript Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers a script with this skill, backed by a C# delegate.
The delegate's parameters and return type are automatically marshaled via AIFunctionFactory.
public Microsoft.Agents.AI.AgentInlineSkill AddScript(string name, Delegate method, string? description = default, System.Text.Json.JsonSerializerOptions? serializerOptions = default);
member this.AddScript : string * Delegate * string * System.Text.Json.JsonSerializerOptions -> Microsoft.Agents.AI.AgentInlineSkill
Public Function AddScript (name As String, method As Delegate, Optional description As String = Nothing, Optional serializerOptions As JsonSerializerOptions = Nothing) As AgentInlineSkill
Parameters
- name
- String
The script name.
- method
- Delegate
A method to execute when the script is invoked.
- description
- String
An optional description of the script.
- serializerOptions
- JsonSerializerOptions
Optional JsonSerializerOptions for this script's delegate marshaling.
When null, the skill-level default (if any) is used; otherwise DefaultOptions is used.
Returns
This instance, for chaining.
Remarks
The script is listed in the <available_scripts> block of the skill body so the LLM knows it can be called. When no scripts are registered, the block is emitted as a self-closing element to signal that none exist, preventing hallucinated script calls.