Skip to content

Commit 529cfa0

Browse files
authored
Make id required for McpToolCallApprovalRequestItem (#671)
Replaced the constructor that does not take the item ID as a parameter in favor of one that does. 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".
1 parent f68f162 commit 529cfa0

File tree

7 files changed

+47
-20
lines changed

7 files changed

+47
-20
lines changed

api/OpenAI.net8.0.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4922,7 +4922,7 @@ public class McpToolCallApprovalPolicy : IJsonModel<McpToolCallApprovalPolicy>,
49224922
}
49234923
[Experimental("OPENAI001")]
49244924
public class McpToolCallApprovalRequestItem : ResponseItem, IJsonModel<McpToolCallApprovalRequestItem>, IPersistableModel<McpToolCallApprovalRequestItem> {
4925-
public McpToolCallApprovalRequestItem(string serverLabel, string toolName, BinaryData toolArguments);
4925+
public McpToolCallApprovalRequestItem(string id, string serverLabel, string toolName, BinaryData toolArguments);
49264926
public string ServerLabel { get; set; }
49274927
public BinaryData ToolArguments { get; set; }
49284928
public string ToolName { get; set; }
@@ -5310,7 +5310,7 @@ public class ResponseItem : IJsonModel<ResponseItem>, IPersistableModel<Response
53105310
public static FileSearchCallResponseItem CreateFileSearchCallItem(IEnumerable<string> queries);
53115311
public static FunctionCallResponseItem CreateFunctionCallItem(string callId, string functionName, BinaryData functionArguments);
53125312
public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string callId, string functionOutput);
5313-
public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string serverLabel, string name, BinaryData arguments);
5313+
public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string id, string serverLabel, string name, BinaryData arguments);
53145314
public static McpToolCallApprovalResponseItem CreateMcpApprovalResponseItem(string approvalRequestId, bool approved);
53155315
public static McpToolCallItem CreateMcpToolCallItem(string serverLabel, string name, BinaryData arguments);
53165316
public static McpToolDefinitionListItem CreateMcpToolDefinitionListItem(string serverLabel, IEnumerable<McpToolDefinition> toolDefinitions);

api/OpenAI.netstandard2.0.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4326,7 +4326,7 @@ public class McpToolCallApprovalPolicy : IJsonModel<McpToolCallApprovalPolicy>,
43264326
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
43274327
}
43284328
public class McpToolCallApprovalRequestItem : ResponseItem, IJsonModel<McpToolCallApprovalRequestItem>, IPersistableModel<McpToolCallApprovalRequestItem> {
4329-
public McpToolCallApprovalRequestItem(string serverLabel, string toolName, BinaryData toolArguments);
4329+
public McpToolCallApprovalRequestItem(string id, string serverLabel, string toolName, BinaryData toolArguments);
43304330
public string ServerLabel { get; set; }
43314331
public BinaryData ToolArguments { get; set; }
43324332
public string ToolName { get; set; }
@@ -4684,7 +4684,7 @@ public class ResponseItem : IJsonModel<ResponseItem>, IPersistableModel<Response
46844684
public static FileSearchCallResponseItem CreateFileSearchCallItem(IEnumerable<string> queries);
46854685
public static FunctionCallResponseItem CreateFunctionCallItem(string callId, string functionName, BinaryData functionArguments);
46864686
public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string callId, string functionOutput);
4687-
public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string serverLabel, string name, BinaryData arguments);
4687+
public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string id, string serverLabel, string name, BinaryData arguments);
46884688
public static McpToolCallApprovalResponseItem CreateMcpApprovalResponseItem(string approvalRequestId, bool approved);
46894689
public static McpToolCallItem CreateMcpToolCallItem(string serverLabel, string name, BinaryData arguments);
46904690
public static McpToolDefinitionListItem CreateMcpToolDefinitionListItem(string serverLabel, IEnumerable<McpToolDefinition> toolDefinitions);

specification/client/responses.client.tsp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ using Azure.ClientGenerator.Core;
77
@@alternateType(CreateResponse.service_tier, DotNetResponseServiceTier);
88
@@alternateType(Response.service_tier, DotNetResponseServiceTier);
99

10-
@@visibility(ItemResource.id, Lifecycle.Read);
10+
// ------------ ItemResources ------------
1111
@@usage(ItemResource, Usage.input | Usage.output);
12+
@@visibility(ItemResource.id, Lifecycle.Read);
1213

1314
@@visibility(ComputerToolCallItemResource.status, Lifecycle.Read);
1415

@@ -31,13 +32,6 @@ using Azure.ClientGenerator.Core;
3132

3233
@@visibility(ResponsesMessageItemResource.status, Lifecycle.Read);
3334

34-
@@clientName(FileSearchTool.max_num_results, "MaxResultCount");
35-
36-
@@clientName(FunctionTool.name, "FunctionName");
37-
@@clientName(FunctionTool.description, "FunctionDescription");
38-
@@clientName(FunctionTool.parameters, "FunctionParameters");
39-
@@clientName(FunctionTool.strict, "StrictModeEnabled");
40-
4135
@@alternateType(MCPApprovalRequestItemResource.arguments, unknown);
4236
@@clientName(MCPApprovalRequestItemResource.name, "ToolName");
4337
@@clientName(MCPApprovalRequestItemResource.arguments, "ToolArguments");
@@ -53,9 +47,20 @@ using Azure.ClientGenerator.Core;
5347
@@alternateType(MCPListToolsItemResource.error, unknown);
5448
@@clientName(MCPListToolsItemResource.tools, "ToolDefinitions");
5549

50+
// ------------ Tools ------------
51+
52+
@@clientName(FileSearchTool.max_num_results, "MaxResultCount");
53+
54+
@@clientName(FunctionTool.name, "FunctionName");
55+
@@clientName(FunctionTool.description, "FunctionDescription");
56+
@@clientName(FunctionTool.parameters, "FunctionParameters");
57+
@@clientName(FunctionTool.strict, "StrictModeEnabled");
58+
5659
@@alternateType(MCPTool.server_url, url);
5760
@@clientName(MCPTool.server_url, "ServerUri");
5861

62+
// ------------ Streaming ------------
63+
5964
@@alternateType(ResponseFunctionCallArgumentsDoneEvent.arguments, unknown);
6065
// @@clientName(ResponseFunctionCallArgumentsDoneEvent.arguments, "FunctionArguments");
6166

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1-
namespace OpenAI.Responses;
1+
using System;
22

3-
// CUSTOM: Renamed.
3+
namespace OpenAI.Responses;
4+
5+
// CUSTOM:
6+
// - Renamed.
7+
// - Made internal the constructor that does not take the item ID as a parameter. This is because MCP
8+
// approval requests are correlated to MCP approval responses using this ID. Therefore, it
9+
// implies that the ID of MCP approval requests is required. Note that this is contrary to other
10+
// similar cases, such as function call items, which are instead correlated to function call
11+
// outputs using a dedicated "call ID".
412
[CodeGenType("MCPApprovalRequestItemResource")]
13+
[CodeGenVisibility(nameof(McpToolCallApprovalRequestItem), CodeGenVisibility.Internal, typeof(string), typeof(string), typeof(BinaryData))]
514
public partial class McpToolCallApprovalRequestItem
615
{
16+
// CUSTOM: Added a constructor that takes the item ID.
17+
public McpToolCallApprovalRequestItem(string id, string serverLabel, string toolName, BinaryData toolArguments) : base(InternalItemType.McpApprovalRequest)
18+
{
19+
Argument.AssertNotNull(id, nameof(id));
20+
Argument.AssertNotNull(serverLabel, nameof(serverLabel));
21+
Argument.AssertNotNull(toolName, nameof(toolName));
22+
Argument.AssertNotNull(toolArguments, nameof(toolArguments));
23+
24+
Id = id;
25+
ServerLabel = serverLabel;
26+
ToolName = toolName;
27+
ToolArguments = toolArguments;
28+
}
729
}

src/Custom/Responses/Items/Reference/ReferenceResponseItem.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ namespace OpenAI.Responses;
22

33
// CUSTOM:
44
// - Renamed.
5-
// - Made internal the constructor that does not take an ID, because contrary to other item types,
6-
// the ID of reference items is not read-only and is required.
5+
// - Made internal the constructor that does not take the item ID, because contrary to other item
6+
// types, the ID of reference items is not read-only and is required.
77
[CodeGenType("DotNetItemReferenceItemResource")]
88
[CodeGenVisibility(nameof(ReferenceResponseItem), CodeGenVisibility.Internal)]
99
public partial class ReferenceResponseItem
1010
{
11-
// CUSTOM: Added a constructor that takes an ID.
11+
// CUSTOM: Added a constructor that takes the item ID.
1212
public ReferenceResponseItem(string id) : base(InternalItemType.ItemReference)
1313
{
1414
Argument.AssertNotNull(id, nameof(id));

src/Custom/Responses/Items/ResponseItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ public static ReferenceResponseItem CreateReferenceItem(string id)
116116
return new ReferenceResponseItem(id);
117117
}
118118

119-
public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string serverLabel, string name, BinaryData arguments)
119+
public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string id, string serverLabel, string name, BinaryData arguments)
120120
{
121-
return new McpToolCallApprovalRequestItem(serverLabel, name, arguments);
121+
return new McpToolCallApprovalRequestItem(id, serverLabel, name, arguments);
122122
}
123123

124124
public static McpToolCallApprovalResponseItem CreateMcpApprovalResponseItem(string approvalRequestId, bool approved)

src/Generated/Models/Responses/McpToolCallApprovalRequestItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace OpenAI.Responses
1212
[Experimental("OPENAI001")]
1313
public partial class McpToolCallApprovalRequestItem : ResponseItem
1414
{
15-
public McpToolCallApprovalRequestItem(string serverLabel, string toolName, BinaryData toolArguments) : base(InternalItemType.McpApprovalRequest)
15+
internal McpToolCallApprovalRequestItem(string serverLabel, string toolName, BinaryData toolArguments) : base(InternalItemType.McpApprovalRequest)
1616
{
1717
Argument.AssertNotNull(serverLabel, nameof(serverLabel));
1818
Argument.AssertNotNull(toolName, nameof(toolName));

0 commit comments

Comments
 (0)