Files
agent-framework/dotnet/src/Microsoft.Agents.AI/Skills/AggregatingAgentSkillsSource.cs
T
SergeyMenshykhandGitHub 0fcbe7e105 .NET: [Breaking] Restructure agent skills to use multi-source architecture (#4871)
* initial commit

* address comments

* address comments

* address comments

* address  comments

* rename executor to runner to align naming with python implementation

* rename runner execute method to run method

* remove poc leftovers and fix compilation issues

* make script runner optional

* remove unnecessary pragmas

* make resources and scripts props virtual

* address comments

* update comment for name validation regex

* address comments
2026-03-26 22:27:17 +00:00

46 lines
1.5 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Agents.AI;
/// <summary>
/// A skill source that aggregates multiple child sources, preserving their registration order.
/// </summary>
/// <remarks>
/// Skills from each child source are returned in the order the sources were registered,
/// with each source's skills appended sequentially. No deduplication or filtering is applied.
/// </remarks>
[Experimental(DiagnosticIds.Experiments.AgentsAIExperiments)]
internal sealed class AggregatingAgentSkillsSource : AgentSkillsSource
{
private readonly IEnumerable<AgentSkillsSource> _sources;
/// <summary>
/// Initializes a new instance of the <see cref="AggregatingAgentSkillsSource"/> class.
/// </summary>
/// <param name="sources">The child sources to aggregate.</param>
public AggregatingAgentSkillsSource(IEnumerable<AgentSkillsSource> sources)
{
this._sources = Throw.IfNull(sources);
}
/// <inheritdoc/>
public override async Task<IList<AgentSkill>> GetSkillsAsync(CancellationToken cancellationToken = default)
{
var allSkills = new List<AgentSkill>();
foreach (var source in this._sources)
{
var skills = await source.GetSkillsAsync(cancellationToken).ConfigureAwait(false);
allSkills.AddRange(skills);
}
return allSkills;
}
}