.NET: AgentHostExecutor should use agent DisplayName as Executor ID (#1840)

* AgentHostExecutor should use agent DisplayName as Executor ID

* Address comments

* Remove unintended changes

* Remove unintended changes

* Fix tests and address comments
This commit is contained in:
Tao Chen
2025-11-05 22:16:53 +00:00
committed by GitHub
parent 0bf6d437d8
commit 3f835c8118
3 changed files with 49 additions and 2 deletions
@@ -11,7 +11,7 @@ namespace Microsoft.Agents.AI.Workflows;
/// <param name="Agent">The AI agent.</param>
/// <param name="EmitEvents">Specifies whether the agent should emit events. If null, the default behavior is applied.</param>
public record AIAgentBinding(AIAgent Agent, bool EmitEvents = false)
: ExecutorBinding(Throw.IfNull(Agent).Name ?? Throw.IfNull(Agent.Id),
: ExecutorBinding(Throw.IfNull(Agent).GetDescriptiveId(),
(_) => new(new AIAgentHostExecutor(Agent, EmitEvents)),
typeof(AIAgentHostExecutor),
Agent)
@@ -14,7 +14,7 @@ internal sealed class AIAgentHostExecutor : ChatProtocolExecutor
private readonly AIAgent _agent;
private AgentThread? _thread;
public AIAgentHostExecutor(AIAgent agent, bool emitEvents = false) : base(id: agent.Id)
public AIAgentHostExecutor(AIAgent agent, bool emitEvents = false) : base(id: agent.GetDescriptiveId())
{
this._agent = agent;
this._emitEvents = emitEvents;