Skip to main content

Fixed: MEAI001 'Microsoft.Extensions.AI.AIFunctionNameAttribute' is for evaluation purposes only

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

I gave a Microsoft Agent Framework function tool its name with the [AIFunctionName] attribute, and the build failed: error MEAI001: 'Microsoft.Extensions.AI.AIFunctionNameAttribute' is for evaluation purposes only and is subject to change or removal in future updates. The attribute is experimental in the Microsoft.Extensions.AI version Agent Framework 1.28 uses. [DisplayName], or the name parameter of AIFunctionFactory.Create, named the tool without it.

What I Was Doing​

While writing the Function Tools tutorial, I found that a tool made from a local function gets a name the compiler made up, such as _Main_g_GetPizzaPrice_0_0, unless you give it one. The reference for AIFunctionFactory.Create lists the ways to give it a name, and an attribute came first, so I tried it on a small tool in a new console app, with the Agent Framework package Microsoft.Agents.AI.Foundry 1.28.0-preview.261106.1:

Program.cs
using System.ComponentModel;
using Microsoft.Extensions.AI;

AIFunction tool = AIFunctionFactory.Create(FlipCoin);
Console.WriteLine($"The tool's name: {tool.Name}");

[AIFunctionName("flip_coin")]
[Description("Flips a coin and returns heads or tails.")]
static string FlipCoin() => Random.Shared.Next(2) == 0 ? "heads" : "tails";
Terminal
dotnet run

What I Expected​

The tool's name: flip_coin.

What I Got​

The build failed on the attribute:

Output
/Users/you/source/ToolName/Program.cs(7,2): error MEAI001: 'Microsoft.Extensions.AI.AIFunctionNameAttribute' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. (https://aka.ms/dotnet-extensions-warnings/MEAI001)

The build failed. Fix the build errors and run again.

macOS-style terminal window titled Terminal — ToolName showing dotnet run failing with error MEAI001: Microsoft.Extensions.AI.AIFunctionNameAttribute is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed, and The build failed

What I Checked​

The link in the error. https://aka.ms/dotnet-extensions-warnings/MEAI001 didn't lead to an explanation: on the day I tried it, it redirected to Bing's home page.

The reference for AIFunctionFactory.Create. In its newest version, it describes the name parameter: If null, the name will be derived from any AIFunctionNameAttribute on method, then from any DisplayNameAttribute on method, if available, or else from the name of method. So there are three ways besides the method's own name: the name parameter, [AIFunctionName], and [DisplayName] from System.ComponentModel.

Which Microsoft.Extensions.AI the app uses. Agent Framework 1.28 brings in Microsoft.Extensions.AI 10.11.0, and in that version AIFunctionNameAttribute carries the experimental mark the error reports.

What C# says about experimental APIs. The C# compiler's documentation on these messages: If you're consuming an API marked with System.Diagnostics.CodeAnalysis.ExperimentalAttribute, suppress a valid reported diagnostic ID only when you accept that the API can change or be removed. Use #pragma warning disable or add the ID to <NoWarn> in your project file.

Why It Happens​

AIFunctionNameAttribute is experimental in Microsoft.Extensions.AI 10.11.0. Using an experimental API is a compile error until you agree to it, by suppressing its diagnostic ID, here MEAI001. The newest reference already lists the attribute among the ways to name a tool, but the version in the app marks it as subject to change.

The Fix​

Name the tool with something that isn't experimental. [DisplayName] comes from System.ComponentModel, the same namespace as [Description]:

Program.cs
using System.ComponentModel;
using Microsoft.Extensions.AI;

AIFunction tool = AIFunctionFactory.Create(FlipCoin);
Console.WriteLine($"The tool's name: {tool.Name}");

[DisplayName("flip_coin")]
[Description("Flips a coin and returns heads or tails.")]
static string FlipCoin() => Random.Shared.Next(2) == 0 ? "heads" : "tails";

Or keep the method as it is, and give the name where you create the tool: AIFunctionFactory.Create(FlipCoin, name: "flip_coin").

If you want the attribute anyway​

Agree to the experimental API for that one line, as the error suggests. Then a later version can change or remove the attribute:

Program.cs (the attribute, with the diagnostic suppressed)
#pragma warning disable MEAI001 // AIFunctionNameAttribute is experimental: I accept that it may change.
[AIFunctionName("flip_coin")]
#pragma warning restore MEAI001
[Description("Flips a coin and returns heads or tails.")]
static string FlipCoin() => Random.Shared.Next(2) == 0 ? "heads" : "tails";

After the Fix​

Output
The tool's name: flip_coin

macOS-style window titled Program.cs — ToolName with two panes: above, the FlipCoin local function with DisplayName flip_coin and a Description; below, dotnet run printing The tool's name: flip_coin

The version with #pragma warning disable MEAI001 built too, and printed the same name.

Common Mistakes​

MistakeWhat happensDo this instead
Using [AIFunctionName] with Microsoft.Extensions.AI 10.11.0error MEAI001, and the build failsUse [DisplayName] or name:
Suppressing every experimental warning in the projectYou also agree to experimental APIs you never choseSuppress only MEAI001, and only where you use it
Leaving a local function's tool unnamedThe model sees a compiler-made name, such as _Main_g_GetPizzaPrice_0_0Give it a name one of the ways above

Troubleshooting​

SymptomLikely causeFix
error MEAI001: '…AIFunctionNameAttribute' is for evaluation purposes onlyThe attribute is experimental in your Microsoft.Extensions.AI[DisplayName], name:, or suppress MEAI001
The link in the error goes to BingThe short link doesn't lead to a pageRead the C# documentation on experimental APIs instead

FAQ​

Which way should I use?​

name: when you create the tool keeps the name next to the code that registers it. [DisplayName] keeps it on the method, which helps when the method is used in several places. Both are stable.

Will [AIFunctionName] stop being experimental?​

The reference already lists it first, so it may. Until your version of Microsoft.Extensions.AI drops the experimental mark, it needs the suppression.

Conclusion​

MEAI001 on AIFunctionNameAttribute means the attribute is experimental in the Microsoft.Extensions.AI version you use. Name the tool with [DisplayName] or with the name parameter of AIFunctionFactory.Create instead, or suppress MEAI001 for that attribute if you accept that it may change.

Additional Resources​