Skip to content

Commit f71bb99

Browse files
committed
Make id required for McpToolCallApprovalRequestItem
1 parent e4963f0 commit f71bb99

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
@@ -4910,7 +4910,7 @@ public class McpToolCallApprovalPolicy : IJsonModel<McpToolCallApprovalPolicy>,
49104910
}
49114911
[Experimental("OPENAI001")]
49124912
public class McpToolCallApprovalRequestItem : ResponseItem, IJsonModel<McpToolCallApprovalRequestItem>, IPersistableModel<McpToolCallApprovalRequestItem> {
4913-
public McpToolCallApprovalRequestItem(string serverLabel, string toolName, BinaryData toolArguments);
4913+
public McpToolCallApprovalRequestItem(string id, string serverLabel, string toolName, BinaryData toolArguments);
49144914
public string ServerLabel { get; set; }
49154915
public BinaryData ToolArguments { get; set; }
49164916
public string ToolName { get; set; }
@@ -5298,7 +5298,7 @@ public class ResponseItem : IJsonModel<ResponseItem>, IPersistableModel<Response
52985298
public static FileSearchCallResponseItem CreateFileSearchCallItem(IEnumerable<string> queries);
52995299
public static FunctionCallResponseItem CreateFunctionCallItem(string callId, string functionName, BinaryData functionArguments);
53005300
public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string callId, string functionOutput);
5301-
public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string serverLabel, string name, BinaryData arguments);
5301+
public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string id, string serverLabel, string name, BinaryData arguments);
53025302
public static McpToolCallApprovalResponseItem CreateMcpApprovalResponseItem(string approvalRequestId, bool approved);
53035303
public static McpToolCallItem CreateMcpToolCallItem(string serverLabel, string name, BinaryData arguments);
53045304
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
@@ -4314,7 +4314,7 @@ public class McpToolCallApprovalPolicy : IJsonModel<McpToolCallApprovalPolicy>,
43144314
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
43154315
}
43164316
public class McpToolCallApprovalRequestItem : ResponseItem, IJsonModel<McpToolCallApprovalRequestItem>, IPersistableModel<McpToolCallApprovalRequestItem> {
4317-
public McpToolCallApprovalRequestItem(string serverLabel, string toolName, BinaryData toolArguments);
4317+
public McpToolCallApprovalRequestItem(string id, string serverLabel, string toolName, BinaryData toolArguments);
43184318
public string ServerLabel { get; set; }
43194319
public BinaryData ToolArguments { get; set; }
43204320
public string ToolName { get; set; }
@@ -4672,7 +4672,7 @@ public class ResponseItem : IJsonModel<ResponseItem>, IPersistableModel<Response
46724672
public static FileSearchCallResponseItem CreateFileSearchCallItem(IEnumerable<string> queries);
46734673
public static FunctionCallResponseItem CreateFunctionCallItem(string callId, string functionName, BinaryData functionArguments);
46744674
public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string callId, string functionOutput);
4675-
public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string serverLabel, string name, BinaryData arguments);
4675+
public static McpToolCallApprovalRequestItem CreateMcpApprovalRequestItem(string id, string serverLabel, string name, BinaryData arguments);
46764676
public static McpToolCallApprovalResponseItem CreateMcpApprovalResponseItem(string approvalRequestId, bool approved);
46774677
public static McpToolCallItem CreateMcpToolCallItem(string serverLabel, string name, BinaryData arguments);
46784678
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)