mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
03a403d2fa
* 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.
32 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|