Thanks to visit codestin.com
Credit goes to github.com

Skip to content

.NET: [Bug]: Tool calling is not working properly. #5490

Description

@skillmaker-dev

Description

Hey, I'm currently trying this package in an ASP.NET 10 app, using the latest version of the package Microsoft.Agents.AI.OpenAI 1.3.0 , I'm creating agents using OpenAI Client with Openrouter as a provider.

The problem I face is that tool calling is not working properly with params. I tell it to use the search param, but it doesn't use it at all, and this happens with any model I try, including Minimax 2.7, Kimi 2.6, Gemini flash 3.1...

Here is an interaction example using DevUI:

Image Image Image Image

As you can see, the search param is always null, even on retries. Take a look at the code example below:

[Description("List projects (source code repositories / applications) in the current organization. Returns each project's ID, name, reference, status, and repository URL. FORBIDDEN to call if you already have project results from a prior tool result in this conversation — use the IDs you already have.")]
public async Task<string> ListProjects(
    [Description("Optional search term to filter projects by name. If the user names a project, copy that exact text here.")] string? search = null,
    [Description("Maximum number of results to return (default 20, max 50). Use 50 when the user asks for 'all' projects.")] int? limit = null,
    CancellationToken cancellationToken = default)
{
// rest of the code.
}

The issue occurs even if I remove = null from the params.

The system prompt also includes examples to call tools.

Any idea where the issue could be?

Code Sample

services.AddAIAgent(AgentKey.GlobalChat, (sp, _) =>
{
    var config = AgentConfiguration.GetConfiguration(AgentKey.GlobalChat);
    var chatClient = sp.GetRequiredKeyedService<IChatClient>(defaultModelId);

    var scope = sp.CreateScope();
    var scopedProvider = scope.ServiceProvider;

    var tools = config.EnabledToolProviderTypes
        .Select(toolType => scopedProvider.GetService(toolType))
        .OfType<IToolProvider>()
        .SelectMany(provider => provider.GetTools())
        .ToList();

    return new ChatClientAgent(chatClient, new ChatClientAgentOptions
    {
        Name = AgentKey.GlobalChat,
        ChatOptions = new()
        {
            Instructions = config.SystemPrompt,
            Tools = tools
        }
    });
});

Error Messages / Stack Traces

Package Versions

PackageReference Include="Microsoft.Agents.AI.OpenAI 1.3.0

.NET Version

.NET 10

Additional Context

No response

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .NetbugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)

Type

Fields

No fields configured for Bug.

Projects

Status
Planned

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions