Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task RunWithAzureAIAgentsPersistent()
instructions: JokerInstructions);

// Get a local proxy for the agent to work with.
Agent agent = await persistentAgentsClient.GetRunnableAgentAsync(createPersistentAgentResponse.Value.Id);
AIAgent agent = await persistentAgentsClient.GetRunnableAgentAsync(createPersistentAgentResponse.Value.Id);

// Start a new thread for the agent conversation.
AgentThread thread = agent.GetNewThread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task RunBasic(ChatClientProviders provider)
IChatClient chatClient = base.GetChatClient(provider);

// Define the agent
Agent agent = new ChatClientAgent(chatClient, ParrotInstructions, ParrotName);
AIAgent agent = new ChatClientAgent(chatClient, ParrotInstructions, ParrotName);

// Invoke the agent and output the text result.
Console.WriteLine(await agent.RunAsync("Fortune favors the bold."));
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/Microsoft.Agents.Orchestration/AgentActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class AgentActor : OrchestrationActor
/// <param name="context">The orchestration context.</param>
/// <param name="agent">An <see cref="Agent"/>.</param>
/// <param name="logger">The logger to use for the actor</param>
protected AgentActor(ActorId id, IAgentRuntime runtime, OrchestrationContext context, Agent agent, ILogger? logger = null)
protected AgentActor(ActorId id, IAgentRuntime runtime, OrchestrationContext context, AIAgent agent, ILogger? logger = null)
: base(id, runtime, context, agent.Description, logger)
{
this.Agent = agent;
Expand All @@ -34,7 +34,7 @@ protected AgentActor(ActorId id, IAgentRuntime runtime, OrchestrationContext con
/// <summary>
/// Gets the associated agent.
/// </summary>
protected Agent Agent { get; }
protected AIAgent Agent { get; }

/// <summary>
/// Gets the current conversation thread used during agent communication.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract partial class AgentOrchestration<TInput, TOutput>
/// Initializes a new instance of the <see cref="AgentOrchestration{TInput, TOutput}"/> class.
/// </summary>
/// <param name="members">Specifies the member agents or orchestrations participating in this orchestration.</param>
protected AgentOrchestration(params Agent[] members)
protected AgentOrchestration(params AIAgent[] members)
{
_ = Throw.IfNull(members);

Expand Down Expand Up @@ -87,7 +87,7 @@ protected AgentOrchestration(params Agent[] members)
/// <summary>
/// Gets the list of member targets involved in the orchestration.
/// </summary>
protected IReadOnlyList<Agent> Members { get; }
protected IReadOnlyList<AIAgent> Members { get; }

/// <summary>
/// Orchestration identifier without generic parameters for use in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ internal sealed class ConcurrentActor : AgentActor
/// <param name="id">The unique identifier of the agent.</param>
/// <param name="runtime">The runtime associated with the agent.</param>
/// <param name="context">The orchestration context.</param>
/// <param name="agent">An <see cref="Agent"/>.</param>
/// <param name="agent">An <see cref="AIAgent"/>.</param>
/// <param name="resultActor">Identifies the actor collecting results.</param>
/// <param name="logger">The logger to use for the actor</param>
public ConcurrentActor(ActorId id, IAgentRuntime runtime, OrchestrationContext context, Agent agent, ActorType resultActor, ILogger<ConcurrentActor>? logger = null)
public ConcurrentActor(ActorId id, IAgentRuntime runtime, OrchestrationContext context, AIAgent agent, ActorType resultActor, ILogger<ConcurrentActor>? logger = null)
: base(id, runtime, context, agent, logger)
{
this._handoffActor = resultActor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed class ConcurrentOrchestration : ConcurrentOrchestration<string, st
/// Initializes a new instance of the <see cref="ConcurrentOrchestration"/> class.
/// </summary>
/// <param name="members">The agents to be orchestrated.</param>
public ConcurrentOrchestration(params Agent[] members)
public ConcurrentOrchestration(params AIAgent[] members)
: base(members)
{
this.ResultTransform =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ConcurrentOrchestration<TInput, TOutput>
/// Initializes a new instance of the <see cref="ConcurrentOrchestration{TInput, TOutput}"/> class.
/// </summary>
/// <param name="agents">The agents participating in the orchestration.</param>
public ConcurrentOrchestration(params Agent[] agents)
public ConcurrentOrchestration(params AIAgent[] agents)
: base(agents)
{
}
Expand Down Expand Up @@ -52,7 +52,7 @@ await runtime.RegisterOrchestrationAgentAsync(

// Register member actors - All agents respond to the same message.
int agentCount = 0;
foreach (Agent agent in this.Members)
foreach (AIAgent agent in this.Members)
{
++agentCount;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ internal sealed class GroupChatAgentActor : AgentActor
/// <param name="id">The unique identifier of the agent.</param>
/// <param name="runtime">The runtime associated with the agent.</param>
/// <param name="context">The orchestration context.</param>
/// <param name="agent">An <see cref="Agent"/>.</param>
/// <param name="agent">An <see cref="AIAgent"/>.</param>
/// <param name="logger">The logger to use for the actor</param>
public GroupChatAgentActor(ActorId id, IAgentRuntime runtime, OrchestrationContext context, Agent agent, ILogger<GroupChatAgentActor>? logger = null)
public GroupChatAgentActor(ActorId id, IAgentRuntime runtime, OrchestrationContext context, AIAgent agent, ILogger<GroupChatAgentActor>? logger = null)
: base(id, runtime, context, agent, logger)
{
this._cache = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class GroupChatOrchestration : GroupChatOrchestration<string, stri
/// </summary>
/// <param name="manager">The manages the flow of the group-chat.</param>
/// <param name="members">The agents to be orchestrated.</param>
public GroupChatOrchestration(GroupChatManager manager, params Agent[] members)
public GroupChatOrchestration(GroupChatManager manager, params AIAgent[] members)
: base(manager, members)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class GroupChatOrchestration<TInput, TOutput> :
/// </summary>
/// <param name="manager">The manages the flow of the group-chat.</param>
/// <param name="agents">The agents participating in the orchestration.</param>
public GroupChatOrchestration(GroupChatManager manager, params Agent[] agents)
public GroupChatOrchestration(GroupChatManager manager, params AIAgent[] agents)
: base(agents)
{
Throw.IfNull(manager, nameof(manager));
Expand All @@ -51,7 +51,7 @@ protected override ValueTask StartAsync(IAgentRuntime runtime, TopicId topic, IE

int agentCount = 0;
GroupChatTeam team = [];
foreach (Agent agent in this.Members)
foreach (AIAgent agent in this.Members)
{
++agentCount;
ActorType agentType = await RegisterAgentAsync(agent, agentCount).ConfigureAwait(false);
Expand Down Expand Up @@ -79,7 +79,7 @@ await runtime.RegisterOrchestrationAgentAsync(

return managerType;

ValueTask<ActorType> RegisterAgentAsync(Agent agent, int agentCount) =>
ValueTask<ActorType> RegisterAgentAsync(AIAgent agent, int agentCount) =>
runtime.RegisterOrchestrationAgentAsync(
this.FormatAgentType(context.Topic, $"Agent_{agentCount}"),
(agentId, runtime) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal sealed partial class HandoffActor : AgentActor
/// <param name="id">The unique identifier of the agent.</param>
/// <param name="runtime">The runtime associated with the agent.</param>
/// <param name="context">The orchestration context.</param>
/// <param name="agent">An <see cref="Agent"/>.</param>>
/// <param name="agent">An <see cref="AIAgent"/>.</param>>
/// <param name="handoffs">The handoffs available to this agent</param>
/// <param name="resultHandoff">The handoff agent for capturing the result.</param>
/// <param name="logger">The logger to use for the actor</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class HandoffOrchestration : HandoffOrchestration<string, string>
/// </summary>
/// <param name="handoffs">Defines the handoff connections for each agent.</param>
/// <param name="members">The agents to be orchestrated.</param>
public HandoffOrchestration(OrchestrationHandoffs handoffs, params Agent[] members)
public HandoffOrchestration(OrchestrationHandoffs handoffs, params AIAgent[] members)
: base(handoffs, members)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class HandoffOrchestration<TInput, TOutput> : AgentOrchestration<TInput,
/// </summary>
/// <param name="handoffs">Defines the handoff connections for each agent.</param>
/// <param name="agents">Additional agents participating in the orchestration that weren't passed to <paramref name="handoffs"/>.</param>
public HandoffOrchestration(OrchestrationHandoffs handoffs, params Agent[] agents) : base(
public HandoffOrchestration(OrchestrationHandoffs handoffs, params AIAgent[] agents) : base(
agents is { Length: 0 } ? handoffs.Agents.ToArray() :
handoffs.Agents is { Count: 0 } ? agents :
handoffs.Agents.Concat(agents).Distinct().ToArray())
Expand Down Expand Up @@ -74,7 +74,7 @@ protected override async ValueTask StartAsync(IAgentRuntime runtime, TopicId top
ActorType agentType = outputType;
for (int index = this.Members.Count - 1; index >= 0; --index)
{
Agent agent = this.Members[index];
AIAgent agent = this.Members[index];
HandoffLookup map = [];
handoffMap[agent.Name ?? agent.Id] = map;
agentType =
Expand Down
14 changes: 7 additions & 7 deletions dotnet/src/Microsoft.Agents.Orchestration/Handoff/Handoffs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public sealed class OrchestrationHandoffs : Dictionary<string, AgentHandoffs>
/// Initializes a new instance of the <see cref="OrchestrationHandoffs"/> class with no handoff relationships.
/// </summary>
/// <param name="firstAgent">The first agent to be invoked (prior to any handoff).</param>
public OrchestrationHandoffs(Agent firstAgent)
public OrchestrationHandoffs(AIAgent firstAgent)
: this(firstAgent.Name ?? firstAgent.Id)
{
this.Agents.Add(firstAgent);
Expand All @@ -63,7 +63,7 @@ public OrchestrationHandoffs(string firstAgentName)
/// </summary>
/// <param name="source">The source agent.</param>
/// <returns>The updated <see cref="OrchestrationHandoffs"/> instance.</returns>
public static OrchestrationHandoffs StartWith(Agent source) => new(source);
public static OrchestrationHandoffs StartWith(AIAgent source) => new(source);

/// <summary>
/// Adds handoff relationships from a source agent to one or more target agents.
Expand All @@ -72,13 +72,13 @@ public OrchestrationHandoffs(string firstAgentName)
/// <param name="source">The source agent.</param>
/// <param name="targets">The target agents to add as handoff targets for the source agent.</param>
/// <returns>The updated <see cref="OrchestrationHandoffs"/> instance.</returns>
public OrchestrationHandoffs Add(Agent source, params Agent[] targets)
public OrchestrationHandoffs Add(AIAgent source, params AIAgent[] targets)
{
string key = source.Name ?? source.Id;

AgentHandoffs agentHandoffs = this.GetAgentHandoffs(key);

foreach (Agent target in targets)
foreach (AIAgent target in targets)
{
if (string.IsNullOrWhiteSpace(target.Description) && string.IsNullOrWhiteSpace(target.Name))
{
Expand All @@ -101,7 +101,7 @@ public OrchestrationHandoffs Add(Agent source, params Agent[] targets)
/// <param name="target">The target agent.</param>
/// <param name="description">The handoff description.</param>
/// <returns>The updated <see cref="OrchestrationHandoffs"/> instance.</returns>
public OrchestrationHandoffs Add(Agent source, Agent target, string description)
public OrchestrationHandoffs Add(AIAgent source, AIAgent target, string description)
=> this.Add(source.Name ?? source.Id, target.Name ?? target.Id, description);

/// <summary>
Expand All @@ -111,7 +111,7 @@ public OrchestrationHandoffs Add(Agent source, Agent target, string description)
/// <param name="targetName">The target agent's name or ID.</param>
/// <param name="description">The handoff description.</param>
/// <returns>The updated <see cref="OrchestrationHandoffs"/> instance.</returns>
public OrchestrationHandoffs Add(Agent source, string targetName, string description)
public OrchestrationHandoffs Add(AIAgent source, string targetName, string description)
=> this.Add(source.Name ?? source.Id, targetName, description);

/// <summary>
Expand Down Expand Up @@ -139,7 +139,7 @@ private AgentHandoffs GetAgentHandoffs(string key)
return agentHandoffs;
}

internal HashSet<Agent> Agents { get; } = [];
internal HashSet<AIAgent> Agents { get; } = [];
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ internal sealed class SequentialActor : AgentActor
/// <param name="id">The unique identifier of the agent.</param>
/// <param name="runtime">The runtime associated with the agent.</param>
/// <param name="context">The orchestration context.</param>
/// <param name="agent">An <see cref="Agent"/>.</param>
/// <param name="agent">An <see cref="AIAgent"/>.</param>
/// <param name="nextAgent">The identifier of the next agent for which to handoff the result</param>
/// <param name="logger">The logger to use for the actor</param>
public SequentialActor(ActorId id, IAgentRuntime runtime, OrchestrationContext context, Agent agent, ActorType nextAgent, ILogger<SequentialActor>? logger = null)
public SequentialActor(ActorId id, IAgentRuntime runtime, OrchestrationContext context, AIAgent agent, ActorType nextAgent, ILogger<SequentialActor>? logger = null)
: base(id, runtime, context, agent, logger)
{
logger?.LogInformation("ACTOR {ActorId} {NextAgent}", this.Id, nextAgent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class SequentialOrchestration : SequentialOrchestration<string, st
/// Initializes a new instance of the <see cref="SequentialOrchestration"/> class.
/// </summary>
/// <param name="members">The agents to be orchestrated.</param>
public SequentialOrchestration(params Agent[] members)
public SequentialOrchestration(params AIAgent[] members)
: base(members)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SequentialOrchestration<TInput, TOutput> : AgentOrchestration<TInpu
/// Initializes a new instance of the <see cref="SequentialOrchestration{TInput, TOutput}"/> class.
/// </summary>
/// <param name="agents">The agents participating in the orchestration.</param>
public SequentialOrchestration(params Agent[] agents)
public SequentialOrchestration(params AIAgent[] agents)
: base(agents)
{
}
Expand All @@ -44,15 +44,15 @@ protected override async ValueTask StartAsync(IAgentRuntime runtime, TopicId top
ActorType nextAgent = outputType;
for (int index = this.Members.Count - 1; index >= 0; --index)
{
Agent agent = this.Members[index];
AIAgent agent = this.Members[index];
nextAgent = await RegisterAgentAsync(agent, index, nextAgent).ConfigureAwait(false);

logger.LogRegisterActor(this.OrchestrationLabel, nextAgent, "MEMBER", index + 1);
}

return nextAgent;

ValueTask<ActorType> RegisterAgentAsync(Agent agent, int index, ActorType nextAgent) =>
ValueTask<ActorType> RegisterAgentAsync(AIAgent agent, int index, ActorType nextAgent) =>
runtime.RegisterOrchestrationAgentAsync(
this.GetAgentType(context.Topic, index),
(agentId, runtime) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.AI.Agents;
/// Base abstraction for all agents. An agent instance may participate in one or more conversations.
/// A conversation may include one or more agents.
/// </summary>
public abstract class Agent
public abstract class AIAgent
{
/// <summary>
/// Gets the identifier of the agent.
Expand All @@ -27,6 +27,14 @@ public abstract class Agent
/// </summary>
public virtual string? Name { get; }

/// <summary>
/// Gets a display name for the agent, which is either the <see cref="Name"/> or <see cref="Id"/> if the name is not set.
/// </summary>
public virtual string DisplayName
{
get => this.Name ?? this.Id;
}

/// <summary>
/// Gets the description of the agent (optional).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Microsoft.Extensions.AI.Agents;

/// <summary>
/// Represents a single streaming response chunk from an <see cref="Agent"/>.
/// Represents a single streaming response chunk from an <see cref="AIAgent"/>.
/// </summary>
/// <remarks>
/// <para>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.Extensions.AI.Agents.CopilotStudio;
/// <summary>
/// Represents a Copilot Studio agent in the cloud.
/// </summary>
public class CopilotStudioAgent : Agent
public class CopilotStudioAgent : AIAgent
{
private readonly ILogger _logger;

Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/Microsoft.Extensions.AI.Agents/AgentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Microsoft.Extensions.AI.Agents;

/// <summary>
/// Extension methods for <see cref="Agent"/>.
/// Extension methods for <see cref="AIAgent"/>.
/// </summary>
public static class AgentExtensions
{
Expand All @@ -13,7 +13,7 @@ public static class AgentExtensions
/// <param name="agent">The agent to wrap.</param>
/// <param name="sourceName">An optional source name that will be used on the telemetry data.</param>
/// <returns>An <see cref="OpenTelemetryAgent"/> that wraps the original agent with telemetry.</returns>
public static OpenTelemetryAgent WithOpenTelemetry(this Agent agent, string? sourceName = null)
public static OpenTelemetryAgent WithOpenTelemetry(this AIAgent agent, string? sourceName = null)
{
return new OpenTelemetryAgent(agent, sourceName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.Extensions.AI.Agents;
/// <summary>
/// Represents an agent that can be invoked using a chat client.
/// </summary>
public sealed class ChatClientAgent : Agent
public sealed class ChatClientAgent : AIAgent
{
private readonly ChatClientAgentOptions? _agentOptions;
private readonly ILogger _logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ namespace Microsoft.Extensions.AI.Agents;
/// This class provides telemetry instrumentation for agent operations including activities, metrics, and logging.
/// The telemetry output follows OpenTelemetry semantic conventions in <see href="https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-agent-spans/"/> and is subject to change as the conventions evolve.
/// </remarks>
public sealed class OpenTelemetryAgent : Agent, IDisposable
public sealed class OpenTelemetryAgent : AIAgent, IDisposable
{
private readonly Agent _innerAgent;
private readonly AIAgent _innerAgent;
private readonly ActivitySource _activitySource;
private readonly Meter _meter;
private readonly Histogram<double> _operationDurationHistogram;
Expand All @@ -32,7 +32,7 @@ public sealed class OpenTelemetryAgent : Agent, IDisposable
/// </summary>
/// <param name="innerAgent">The underlying agent to wrap with telemetry.</param>
/// <param name="sourceName">An optional source name that will be used on the telemetry data.</param>
public OpenTelemetryAgent(Agent innerAgent, string? sourceName = null)
public OpenTelemetryAgent(AIAgent innerAgent, string? sourceName = null)
{
this._innerAgent = Throw.IfNull(innerAgent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace AgentConformance.IntegrationTests;
/// </summary>
public interface IAgentFixture : IAsyncLifetime
{
Agent Agent { get; }
AIAgent Agent { get; }

Task<List<ChatMessage>> GetChatHistoryAsync(AgentThread thread);

Expand Down
Loading
Loading