Skip to content

Local functions used as tool functions could use name cleanup #6677

@kzu

Description

@kzu

Description

There's a bunch of .NET reflection-originating chars in a tool name when it's created from a local function. It would be nice to to additional cleanup to get cleaner tool name by default.

Reproduction Steps

    [Fact]
    public void DefaultToolName()
    {
        static void DoSomething() { }

        var tool = AIFunctionFactory.Create(DoSomething);

        // renders _DefaultToolName_g__DoSomething_4_0
        Assert.Equal("DefaultToolName_DoSomething", tool.Name);
    }

Expected behavior

Since there can't be two members with the same name (neither at the method as well as the local function level), the name could just be DefaultToolName_DoSomething.

Actual behavior

Returns _DefaultToolName_g__DoSomething_4_0

Regression?

No response

Known Workarounds

Set name explicitly

Configuration

net10 preview 6, MEAI 9.7.0

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-aiMicrosoft.Extensions.AI librarieshelp wantedUp for grabs. We would accept a PR to help resolve this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions