Files
agent-framework/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowThread.cs
T
Stephen ToubandGitHub 2539282d30 .NET: Fix some more static analysis diagnostics (#1025)
* S1006

* S2219

* S3236

* S3260

* S1125

* IDE0063

* IDE0062

* IDE0028
2025-09-30 22:50:22 +00:00

49 lines
1.4 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Text.Json;
using Microsoft.Extensions.AI;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Agents.AI.Workflows;
internal sealed class WorkflowThread : AgentThread
{
public WorkflowThread(string workflowId, string? workflowName, string runId)
{
this.MessageStore = new();
this.RunId = Throw.IfNullOrEmpty(runId);
}
public WorkflowThread(JsonElement serializedThread, JsonSerializerOptions? jsonSerializerOptions = null)
{
throw new NotImplementedException("Pending Checkpointing work.");
}
public string RunId { get; }
public int Halts { get; }
public string ResponseId => $"{this.RunId}@{this.Halts}";
public override JsonElement Serialize(JsonSerializerOptions? jsonSerializerOptions = null)
=> throw new NotImplementedException("Pending Checkpointing work.");
public AgentRunResponseUpdate CreateUpdate(params AIContent[] parts)
{
Throw.IfNullOrEmpty(parts);
AgentRunResponseUpdate update = new(ChatRole.Assistant, parts)
{
CreatedAt = DateTimeOffset.UtcNow,
MessageId = Guid.NewGuid().ToString("N"),
};
this.MessageStore.AddMessages(update.ToChatMessage());
return update;
}
/// <inheritdoc/>
public WorkflowMessageStore MessageStore { get; }
}