Files
agent-framework/dotnet/src/Microsoft.Agents.AI.DurableTask/DefaultDurableAgentClient.cs
Phillip Hoff 03a403d2fa .NET: Switch to new "Run" method name. (#2843)
* Switch to new "RunAgent" method name.

* Try to disable false positive naming warning.

* Add comment about disabled warnings.

* Rename `RunAgent` to just `Run`.

* Update CHANGELOG.
2025-12-16 22:07:59 +00:00

32 lines
1.1 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using Microsoft.DurableTask.Client;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
namespace Microsoft.Agents.AI.DurableTask;
internal class DefaultDurableAgentClient(DurableTaskClient client, ILoggerFactory loggerFactory) : IDurableAgentClient
{
private readonly DurableTaskClient _client = client ?? throw new ArgumentNullException(nameof(client));
private readonly ILogger _logger = (loggerFactory ?? NullLoggerFactory.Instance).CreateLogger<DefaultDurableAgentClient>();
public async Task<AgentRunHandle> RunAgentAsync(
AgentSessionId sessionId,
RunRequest request,
CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(request);
this._logger.LogSignallingAgent(sessionId);
await this._client.Entities.SignalEntityAsync(
sessionId,
nameof(AgentEntity.Run),
request,
cancellation: cancellationToken);
return new AgentRunHandle(this._client, this._logger, sessionId, request.CorrelationId);
}
}