Skip to content

.NET: [Bug]: AiAgent skills get overwritten #5224

@HugoVG

Description

@HugoVG

Description

  • When adding Skills onto the agent
builder.Services.AddAIAgent("AI", (service, name) =>
{
    var path = Path.Combine(AppContext.BaseDirectory, "skills");
#pragma warning disable MAAI001
    var skillsProvider = new AgentSkillsProvider(
#pragma warning restore MAAI001
        path);
    var chatClient = service.GetRequiredService<IChatClient>();
    return chatClient.AsAIAgent(new ChatClientAgentOptions()
    {
        ChatOptions = new ChatOptions()
        {
            AllowMultipleToolCalls = true,
        },
        ChatHistoryProvider = service.GetRequiredService<InMemoryChatHistoryProvider>(),
        WarnOnChatHistoryProviderConflict = true,
        ClearOnChatHistoryProviderConflict = true,
        AIContextProviders = [skillsProvider],
        Name = name,
    });
}, ServiceLifetime.Scoped);
  • And having a ChatClientAgentRunOptions, it will no longer use agent skills, there is also no option to add this onto the ChatClientAgentRunOptions
var agentResponse = agent.RunStreamingAsync(request.UserMessage, request.Session,
    new ChatClientAgentRunOptions()
    {
        ChatOptions = new ChatOptions
        {
            ModelId = request.AiModelId,
            AllowMultipleToolCalls = true,
            Tools = [..tools],
            Instructions = sb.ToString(),
            ConversationId = request.ConversationId.ToString(),
            MaxOutputTokens = 32768,
        },
    }, cancellationToken);

Code Sample

Error Messages / Stack Traces

Package Versions

Microsoft.Agents.Ai 1.1.0,

.NET Version

.NET 10

Additional Context

Skill files are loaded and available in during runtime (did check that)

    <!-- Add skills -->
    <ItemGroup>
        <None Include="skills\**\*.*">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
    </ItemGroup>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions