From d8271eda33702805a521604616e17fcd69ec76e6 Mon Sep 17 00:00:00 2001 From: venti <1308199824@qq.com> Date: Sat, 30 May 2026 15:23:17 +0800 Subject: [PATCH] add FunctionApprovalResponseItemParam to fix unrecognized type discriminator (fixes #6006) --- .../OpenAIHostingJsonUtilities.cs | 1 + .../Converters/ItemParamConverter.cs | 1 + .../Responses/Models/ItemParam.cs | 27 +++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/OpenAIHostingJsonUtilities.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/OpenAIHostingJsonUtilities.cs index f77143c583..c5da1ec296 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/OpenAIHostingJsonUtilities.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/OpenAIHostingJsonUtilities.cs @@ -133,6 +133,7 @@ private static JsonSerializerOptions CreateDefaultOptions() [JsonSerializable(typeof(MCPListToolsItemParam))] [JsonSerializable(typeof(MCPApprovalRequestItemParam))] [JsonSerializable(typeof(MCPApprovalResponseItemParam))] +[JsonSerializable(typeof(FunctionApprovalResponseItemParam))] [JsonSerializable(typeof(MCPCallItemParam))] [JsonSerializable(typeof(List))] // ItemContent types diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Converters/ItemParamConverter.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Converters/ItemParamConverter.cs index 9e63bcfd9d..94eff1e34d 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Converters/ItemParamConverter.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Converters/ItemParamConverter.cs @@ -43,6 +43,7 @@ internal sealed class ItemParamConverter : JsonConverter "mcp_list_tools" => doc.Deserialize(OpenAIHostingJsonContext.Default.MCPListToolsItemParam), "mcp_approval_request" => doc.Deserialize(OpenAIHostingJsonContext.Default.MCPApprovalRequestItemParam), "mcp_approval_response" => doc.Deserialize(OpenAIHostingJsonContext.Default.MCPApprovalResponseItemParam), + "function_approval_response" => doc.Deserialize(OpenAIHostingJsonContext.Default.FunctionApprovalResponseItemParam), "mcp_call" => doc.Deserialize(OpenAIHostingJsonContext.Default.MCPCallItemParam), _ => null // Ignore unknown types. }; diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Models/ItemParam.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Models/ItemParam.cs index df8a378df2..5f0d85b28c 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Models/ItemParam.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Models/ItemParam.cs @@ -532,6 +532,33 @@ internal sealed class MCPApprovalResponseItemParam : ItemParam public string? Reason { get; init; } } +/// +/// A function approval response item parameter. +/// This is a non-standard DevUI extension for human-in-the-loop scenarios. +/// +internal sealed class FunctionApprovalResponseItemParam : ItemParam +{ + /// + /// The constant item type identifier for function approval response items. + /// + public const string ItemType = "function_approval_response"; + + /// + public override string Type => ItemType; + + /// + /// The unique identifier of the approval request being responded to. + /// + [JsonPropertyName("request_id")] + public required string RequestId { get; init; } + + /// + /// Gets or sets a value indicating whether the function call was approved. + /// + [JsonPropertyName("approved")] + public bool Approved { get; init; } +} + /// /// An MCP call item parameter. ///