.NET: [Feature Branch] Migrate state schema updates and support for agents as MCP tools (#1979)

This commit is contained in:
Chris Gillum
2025-11-07 09:42:11 -08:00
committed by GitHub
parent 754491cdd3
commit 40b6deff96
59 changed files with 2786 additions and 258 deletions
@@ -0,0 +1,63 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Immutable;
using System.Text.Json.Serialization;
using Microsoft.Extensions.AI;
namespace Microsoft.Agents.AI.DurableTask.State;
/// <summary>
/// Durable agent state content representing a function call.
/// </summary>
internal sealed class DurableAgentStateFunctionCallContent : DurableAgentStateContent
{
/// <summary>
/// The function call arguments.
/// </summary>
/// TODO: Consider ensuring that empty dictionaries are omitted from serialization.
[JsonPropertyName("arguments")]
public required IReadOnlyDictionary<string, object?> Arguments { get; init; } =
ImmutableDictionary<string, object?>.Empty;
/// <summary>
/// Gets the function call identifier.
/// </summary>
/// <remarks>
/// This is used to correlate this function call with its resulting
/// <see cref="DurableAgentStateFunctionResultContent"/>.
/// </remarks>
[JsonPropertyName("callId")]
public required string CallId { get; init; }
/// <summary>
/// Gets the function name.
/// </summary>
[JsonPropertyName("name")]
public required string Name { get; init; }
/// <summary>
/// Creates a <see cref="DurableAgentStateFunctionCallContent"/> from a <see cref="FunctionCallContent"/>.
/// </summary>
/// <param name="content">The <see cref="FunctionCallContent"/> to convert.</param>
/// <returns>
/// A <see cref="DurableAgentStateFunctionCallContent"/> representing the original content.
/// </returns>
public static DurableAgentStateFunctionCallContent FromFunctionCallContent(FunctionCallContent content)
{
return new DurableAgentStateFunctionCallContent()
{
Arguments = content.Arguments?.ToImmutableDictionary() ?? ImmutableDictionary<string, object?>.Empty,
CallId = content.CallId,
Name = content.Name
};
}
/// <inheritdoc/>
public override AIContent ToAIContent()
{
return new FunctionCallContent(
this.CallId,
this.Name,
new Dictionary<string, object?>(this.Arguments));
}
}