From f71bb99bf6d193d2a5df27103736c10b1d467565 Mon Sep 17 00:00:00 2001 From: Jose Arriaga Maldonado Date: Tue, 9 Sep 2025 18:15:16 -0700 Subject: [PATCH] Make id required for McpToolCallApprovalRequestItem --- api/OpenAI.net8.0.cs | 4 +-- api/OpenAI.netstandard2.0.cs | 4 +-- specification/client/responses.client.tsp | 21 +++++++++------ .../McpTool/McpToolCallApprovalRequestItem.cs | 26 +++++++++++++++++-- .../Items/Reference/ReferenceResponseItem.cs | 6 ++--- src/Custom/Responses/Items/ResponseItem.cs | 4 +-- .../McpToolCallApprovalRequestItem.cs | 2 +- 7 files changed, 47 insertions(+), 20 deletions(-) diff --git a/api/OpenAI.net8.0.cs b/api/OpenAI.net8.0.cs index 39963b4c1..18aed9213 100644 --- a/api/OpenAI.net8.0.cs +++ b/api/OpenAI.net8.0.cs @@ -4910,7 +4910,7 @@ public class McpToolCallApprovalPolicy : IJsonModel, } [Experimental("OPENAI001")] public class McpToolCallApprovalRequestItem : ResponseItem, IJsonModel, IPersistableModel { - public McpToolCallApprovalRequestItem(string serverLabel, string toolName, BinaryData toolArguments); + public McpToolCallApprovalRequestItem(string id, string serverLabel, string toolName, BinaryData toolArguments); public string ServerLabel { get; set; } public BinaryData ToolArguments { get; set; } public string ToolName { get; set; } @@ -5298,7 +5298,7 @@ public class ResponseItem : IJsonModel, IPersistableModel queries); public static FunctionCallResponseItem CreateFunctionCallItem(string callId, string functionName, BinaryData functionArguments); public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string callId, string functionOutput); - public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string serverLabel, string name, BinaryData arguments); + public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string id, string serverLabel, string name, BinaryData arguments); public static McpToolCallApprovalResponseItem CreateMcpApprovalResponseItem(string approvalRequestId, bool approved); public static McpToolCallItem CreateMcpToolCallItem(string serverLabel, string name, BinaryData arguments); public static McpToolDefinitionListItem CreateMcpToolDefinitionListItem(string serverLabel, IEnumerable toolDefinitions); diff --git a/api/OpenAI.netstandard2.0.cs b/api/OpenAI.netstandard2.0.cs index ecd1a733c..5986b3ca8 100644 --- a/api/OpenAI.netstandard2.0.cs +++ b/api/OpenAI.netstandard2.0.cs @@ -4314,7 +4314,7 @@ public class McpToolCallApprovalPolicy : IJsonModel, protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options); } public class McpToolCallApprovalRequestItem : ResponseItem, IJsonModel, IPersistableModel { - public McpToolCallApprovalRequestItem(string serverLabel, string toolName, BinaryData toolArguments); + public McpToolCallApprovalRequestItem(string id, string serverLabel, string toolName, BinaryData toolArguments); public string ServerLabel { get; set; } public BinaryData ToolArguments { get; set; } public string ToolName { get; set; } @@ -4672,7 +4672,7 @@ public class ResponseItem : IJsonModel, IPersistableModel queries); public static FunctionCallResponseItem CreateFunctionCallItem(string callId, string functionName, BinaryData functionArguments); public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string callId, string functionOutput); - public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string serverLabel, string name, BinaryData arguments); + public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string id, string serverLabel, string name, BinaryData arguments); public static McpToolCallApprovalResponseItem CreateMcpApprovalResponseItem(string approvalRequestId, bool approved); public static McpToolCallItem CreateMcpToolCallItem(string serverLabel, string name, BinaryData arguments); public static McpToolDefinitionListItem CreateMcpToolDefinitionListItem(string serverLabel, IEnumerable toolDefinitions); diff --git a/specification/client/responses.client.tsp b/specification/client/responses.client.tsp index 3728a8407..2f88ae9b4 100644 --- a/specification/client/responses.client.tsp +++ b/specification/client/responses.client.tsp @@ -7,8 +7,9 @@ using Azure.ClientGenerator.Core; @@alternateType(CreateResponse.service_tier, DotNetResponseServiceTier); @@alternateType(Response.service_tier, DotNetResponseServiceTier); -@@visibility(ItemResource.id, Lifecycle.Read); +// ------------ ItemResources ------------ @@usage(ItemResource, Usage.input | Usage.output); +@@visibility(ItemResource.id, Lifecycle.Read); @@visibility(ComputerToolCallItemResource.status, Lifecycle.Read); @@ -31,13 +32,6 @@ using Azure.ClientGenerator.Core; @@visibility(ResponsesMessageItemResource.status, Lifecycle.Read); -@@clientName(FileSearchTool.max_num_results, "MaxResultCount"); - -@@clientName(FunctionTool.name, "FunctionName"); -@@clientName(FunctionTool.description, "FunctionDescription"); -@@clientName(FunctionTool.parameters, "FunctionParameters"); -@@clientName(FunctionTool.strict, "StrictModeEnabled"); - @@alternateType(MCPApprovalRequestItemResource.arguments, unknown); @@clientName(MCPApprovalRequestItemResource.name, "ToolName"); @@clientName(MCPApprovalRequestItemResource.arguments, "ToolArguments"); @@ -53,9 +47,20 @@ using Azure.ClientGenerator.Core; @@alternateType(MCPListToolsItemResource.error, unknown); @@clientName(MCPListToolsItemResource.tools, "ToolDefinitions"); +// ------------ Tools ------------ + +@@clientName(FileSearchTool.max_num_results, "MaxResultCount"); + +@@clientName(FunctionTool.name, "FunctionName"); +@@clientName(FunctionTool.description, "FunctionDescription"); +@@clientName(FunctionTool.parameters, "FunctionParameters"); +@@clientName(FunctionTool.strict, "StrictModeEnabled"); + @@alternateType(MCPTool.server_url, url); @@clientName(MCPTool.server_url, "ServerUri"); +// ------------ Streaming ------------ + @@alternateType(ResponseFunctionCallArgumentsDoneEvent.arguments, unknown); // @@clientName(ResponseFunctionCallArgumentsDoneEvent.arguments, "FunctionArguments"); diff --git a/src/Custom/Responses/Items/McpTool/McpToolCallApprovalRequestItem.cs b/src/Custom/Responses/Items/McpTool/McpToolCallApprovalRequestItem.cs index 25fe180ac..218845dbe 100644 --- a/src/Custom/Responses/Items/McpTool/McpToolCallApprovalRequestItem.cs +++ b/src/Custom/Responses/Items/McpTool/McpToolCallApprovalRequestItem.cs @@ -1,7 +1,29 @@ -namespace OpenAI.Responses; +using System; -// CUSTOM: Renamed. +namespace OpenAI.Responses; + +// CUSTOM: +// - Renamed. +// - Made internal the constructor that does not take the item ID as a parameter. This is because MCP +// approval requests are correlated to MCP approval responses using this ID. Therefore, it +// implies that the ID of MCP approval requests is required. Note that this is contrary to other +// similar cases, such as function call items, which are instead correlated to function call +// outputs using a dedicated "call ID". [CodeGenType("MCPApprovalRequestItemResource")] +[CodeGenVisibility(nameof(McpToolCallApprovalRequestItem), CodeGenVisibility.Internal, typeof(string), typeof(string), typeof(BinaryData))] public partial class McpToolCallApprovalRequestItem { + // CUSTOM: Added a constructor that takes the item ID. + public McpToolCallApprovalRequestItem(string id, string serverLabel, string toolName, BinaryData toolArguments) : base(InternalItemType.McpApprovalRequest) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(serverLabel, nameof(serverLabel)); + Argument.AssertNotNull(toolName, nameof(toolName)); + Argument.AssertNotNull(toolArguments, nameof(toolArguments)); + + Id = id; + ServerLabel = serverLabel; + ToolName = toolName; + ToolArguments = toolArguments; + } } diff --git a/src/Custom/Responses/Items/Reference/ReferenceResponseItem.cs b/src/Custom/Responses/Items/Reference/ReferenceResponseItem.cs index e99603885..cd614f149 100644 --- a/src/Custom/Responses/Items/Reference/ReferenceResponseItem.cs +++ b/src/Custom/Responses/Items/Reference/ReferenceResponseItem.cs @@ -2,13 +2,13 @@ namespace OpenAI.Responses; // CUSTOM: // - Renamed. -// - Made internal the constructor that does not take an ID, because contrary to other item types, -// the ID of reference items is not read-only and is required. +// - Made internal the constructor that does not take the item ID, because contrary to other item +// types, the ID of reference items is not read-only and is required. [CodeGenType("DotNetItemReferenceItemResource")] [CodeGenVisibility(nameof(ReferenceResponseItem), CodeGenVisibility.Internal)] public partial class ReferenceResponseItem { - // CUSTOM: Added a constructor that takes an ID. + // CUSTOM: Added a constructor that takes the item ID. public ReferenceResponseItem(string id) : base(InternalItemType.ItemReference) { Argument.AssertNotNull(id, nameof(id)); diff --git a/src/Custom/Responses/Items/ResponseItem.cs b/src/Custom/Responses/Items/ResponseItem.cs index b7f61ca7d..ab5b674c6 100644 --- a/src/Custom/Responses/Items/ResponseItem.cs +++ b/src/Custom/Responses/Items/ResponseItem.cs @@ -116,9 +116,9 @@ public static ReferenceResponseItem CreateReferenceItem(string id) return new ReferenceResponseItem(id); } - public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string serverLabel, string name, BinaryData arguments) + public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string id, string serverLabel, string name, BinaryData arguments) { - return new McpToolCallApprovalRequestItem(serverLabel, name, arguments); + return new McpToolCallApprovalRequestItem(id, serverLabel, name, arguments); } public static McpToolCallApprovalResponseItem CreateMcpApprovalResponseItem(string approvalRequestId, bool approved) diff --git a/src/Generated/Models/Responses/McpToolCallApprovalRequestItem.cs b/src/Generated/Models/Responses/McpToolCallApprovalRequestItem.cs index d153f5936..756abecd4 100644 --- a/src/Generated/Models/Responses/McpToolCallApprovalRequestItem.cs +++ b/src/Generated/Models/Responses/McpToolCallApprovalRequestItem.cs @@ -12,7 +12,7 @@ namespace OpenAI.Responses [Experimental("OPENAI001")] public partial class McpToolCallApprovalRequestItem : ResponseItem { - public McpToolCallApprovalRequestItem(string serverLabel, string toolName, BinaryData toolArguments) : base(InternalItemType.McpApprovalRequest) + internal McpToolCallApprovalRequestItem(string serverLabel, string toolName, BinaryData toolArguments) : base(InternalItemType.McpApprovalRequest) { Argument.AssertNotNull(serverLabel, nameof(serverLabel)); Argument.AssertNotNull(toolName, nameof(toolName));