Skip to content

Commit 491cd52

Browse files
fix(api): align SDK response types with expanded item schemas
Fixes a variety of missing Items on Responses. OutputItem: add function_call_output, computer_tool_call_output, local_shell_call_output, mcp_approval_response, custom_tool_call_output ItemResource: add reasoning, compaction, custom_tool_call, custom_tool_call_output
1 parent 27a850e commit 491cd52

5 files changed

Lines changed: 156 additions & 13 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 151
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-13599f99dceef322e19171dcc63d90f638d225a445999442249e1ed7a4924c43.yml
3-
openapi_spec_hash: aac8cf8ec3c7dc6d14ecf5dbb289ee7c
4-
config_hash: 96fbf82cf74a44ccd513f5acf0956ffd
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-00994178cc8e20d71754b00c54b0e4f5b4128e1c1cce765e9b7d696bd8c80d33.yml
3+
openapi_spec_hash: 81f404053b663f987209b4fb2d08a230
4+
config_hash: 5635033cdc8c930255f8b529a78de722

src/resources/conversations/items.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export type ConversationItem =
9191
| ResponsesAPI.ResponseToolSearchCall
9292
| ResponsesAPI.ResponseToolSearchOutputItem
9393
| ResponsesAPI.ResponseReasoningItem
94+
| ResponsesAPI.ResponseCompactionItem
9495
| ResponsesAPI.ResponseCodeInterpreterToolCall
9596
| ConversationItem.LocalShellCall
9697
| ConversationItem.LocalShellCallOutput

src/resources/responses/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ Types:
5151
- <code><a href="./src/resources/responses/responses.ts">ResponseCustomToolCall</a></code>
5252
- <code><a href="./src/resources/responses/responses.ts">ResponseCustomToolCallInputDeltaEvent</a></code>
5353
- <code><a href="./src/resources/responses/responses.ts">ResponseCustomToolCallInputDoneEvent</a></code>
54+
- <code><a href="./src/resources/responses/responses.ts">ResponseCustomToolCallItem</a></code>
5455
- <code><a href="./src/resources/responses/responses.ts">ResponseCustomToolCallOutput</a></code>
56+
- <code><a href="./src/resources/responses/responses.ts">ResponseCustomToolCallOutputItem</a></code>
5557
- <code><a href="./src/resources/responses/responses.ts">ResponseError</a></code>
5658
- <code><a href="./src/resources/responses/responses.ts">ResponseErrorEvent</a></code>
5759
- <code><a href="./src/resources/responses/responses.ts">ResponseFailedEvent</a></code>

src/resources/responses/responses.ts

Lines changed: 143 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,28 @@ export type ParsedResponseOutputItem<ParsedT> =
3939
| ParsedResponseOutputMessage<ParsedT>
4040
| ParsedResponseFunctionToolCall
4141
| ResponseFileSearchToolCall
42+
| ResponseFunctionToolCallOutputItem
4243
| ResponseFunctionWebSearch
4344
| ResponseComputerToolCall
45+
| ResponseComputerToolCallOutputItem
4446
| ResponseToolSearchCall
4547
| ResponseToolSearchOutputItem
4648
| ResponseReasoningItem
4749
| ResponseCompactionItem
4850
| ResponseOutputItem.ImageGenerationCall
4951
| ResponseCodeInterpreterToolCall
5052
| ResponseOutputItem.LocalShellCall
53+
| ResponseOutputItem.LocalShellCallOutput
5154
| ResponseFunctionShellToolCall
5255
| ResponseFunctionShellToolCallOutput
5356
| ResponseApplyPatchToolCall
5457
| ResponseApplyPatchToolCallOutput
5558
| ResponseOutputItem.McpCall
5659
| ResponseOutputItem.McpListTools
5760
| ResponseOutputItem.McpApprovalRequest
58-
| ResponseCustomToolCall;
61+
| ResponseOutputItem.McpApprovalResponse
62+
| ResponseCustomToolCall
63+
| ResponseCustomToolCallOutputItem;
5964

6065
export interface ParsedResponse<ParsedT> extends Response {
6166
output: Array<ParsedResponseOutputItem<ParsedT>>;
@@ -2009,6 +2014,12 @@ export interface ResponseComputerToolCallOutputItem {
20092014
*/
20102015
output: ResponseComputerToolCallOutputScreenshot;
20112016

2017+
/**
2018+
* The status of the message input. One of `in_progress`, `completed`, or
2019+
* `incomplete`. Populated when input items are returned via API.
2020+
*/
2021+
status: 'completed' | 'incomplete' | 'failed' | 'in_progress';
2022+
20122023
/**
20132024
* The type of the computer tool call output. Always `computer_call_output`.
20142025
*/
@@ -2021,10 +2032,9 @@ export interface ResponseComputerToolCallOutputItem {
20212032
acknowledged_safety_checks?: Array<ResponseComputerToolCallOutputItem.AcknowledgedSafetyCheck>;
20222033

20232034
/**
2024-
* The status of the message input. One of `in_progress`, `completed`, or
2025-
* `incomplete`. Populated when input items are returned via API.
2035+
* The identifier of the actor that created the item.
20262036
*/
2027-
status?: 'in_progress' | 'completed' | 'incomplete';
2037+
created_by?: string;
20282038
}
20292039

20302040
export namespace ResponseComputerToolCallOutputItem {
@@ -2339,6 +2349,27 @@ export interface ResponseCustomToolCallInputDoneEvent {
23392349
type: 'response.custom_tool_call_input.done';
23402350
}
23412351

2352+
/**
2353+
* A call to a custom tool created by the model.
2354+
*/
2355+
export interface ResponseCustomToolCallItem extends ResponseCustomToolCall {
2356+
/**
2357+
* The unique ID of the custom tool call item.
2358+
*/
2359+
id: string;
2360+
2361+
/**
2362+
* The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2363+
* Populated when items are returned via API.
2364+
*/
2365+
status: 'in_progress' | 'completed' | 'incomplete';
2366+
2367+
/**
2368+
* The identifier of the actor that created the item.
2369+
*/
2370+
created_by?: string;
2371+
}
2372+
23422373
/**
23432374
* The output of a custom tool call from your code, being sent back to the model.
23442375
*/
@@ -2365,6 +2396,27 @@ export interface ResponseCustomToolCallOutput {
23652396
id?: string;
23662397
}
23672398

2399+
/**
2400+
* The output of a custom tool call from your code, being sent back to the model.
2401+
*/
2402+
export interface ResponseCustomToolCallOutputItem extends ResponseCustomToolCallOutput {
2403+
/**
2404+
* The unique ID of the custom tool call output item.
2405+
*/
2406+
id: string;
2407+
2408+
/**
2409+
* The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2410+
* Populated when items are returned via API.
2411+
*/
2412+
status: 'in_progress' | 'completed' | 'incomplete';
2413+
2414+
/**
2415+
* The identifier of the actor that created the item.
2416+
*/
2417+
created_by?: string;
2418+
}
2419+
23682420
/**
23692421
* An error object returned when the model fails to generate a Response.
23702422
*/
@@ -2982,6 +3034,17 @@ export interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall {
29823034
* The unique ID of the function tool call.
29833035
*/
29843036
id: string;
3037+
3038+
/**
3039+
* The status of the item. One of `in_progress`, `completed`, or `incomplete`.
3040+
* Populated when items are returned via API.
3041+
*/
3042+
status: 'in_progress' | 'completed' | 'incomplete';
3043+
3044+
/**
3045+
* The identifier of the actor that created the item.
3046+
*/
3047+
created_by?: string;
29853048
}
29863049

29873050
export interface ResponseFunctionToolCallOutputItem {
@@ -3001,16 +3064,21 @@ export interface ResponseFunctionToolCallOutputItem {
30013064
*/
30023065
output: string | Array<ResponseInputText | ResponseInputImage | ResponseInputFile>;
30033066

3067+
/**
3068+
* The status of the item. One of `in_progress`, `completed`, or `incomplete`.
3069+
* Populated when items are returned via API.
3070+
*/
3071+
status: 'in_progress' | 'completed' | 'incomplete';
3072+
30043073
/**
30053074
* The type of the function tool call output. Always `function_call_output`.
30063075
*/
30073076
type: 'function_call_output';
30083077

30093078
/**
3010-
* The status of the item. One of `in_progress`, `completed`, or `incomplete`.
3011-
* Populated when items are returned via API.
3079+
* The identifier of the actor that created the item.
30123080
*/
3013-
status?: 'in_progress' | 'completed' | 'incomplete';
3081+
created_by?: string;
30143082
}
30153083

30163084
/**
@@ -4254,6 +4322,8 @@ export type ResponseItem =
42544322
| ResponseFunctionToolCallOutputItem
42554323
| ResponseToolSearchCall
42564324
| ResponseToolSearchOutputItem
4325+
| ResponseReasoningItem
4326+
| ResponseCompactionItem
42574327
| ResponseItem.ImageGenerationCall
42584328
| ResponseCodeInterpreterToolCall
42594329
| ResponseItem.LocalShellCall
@@ -4265,7 +4335,9 @@ export type ResponseItem =
42654335
| ResponseItem.McpListTools
42664336
| ResponseItem.McpApprovalRequest
42674337
| ResponseItem.McpApprovalResponse
4268-
| ResponseItem.McpCall;
4338+
| ResponseItem.McpCall
4339+
| ResponseCustomToolCallItem
4340+
| ResponseCustomToolCallOutputItem;
42694341

42704342
export namespace ResponseItem {
42714343
/**
@@ -4806,23 +4878,28 @@ export type ResponseOutputItem =
48064878
| ResponseOutputMessage
48074879
| ResponseFileSearchToolCall
48084880
| ResponseFunctionToolCall
4881+
| ResponseFunctionToolCallOutputItem
48094882
| ResponseFunctionWebSearch
48104883
| ResponseComputerToolCall
4884+
| ResponseComputerToolCallOutputItem
48114885
| ResponseReasoningItem
48124886
| ResponseToolSearchCall
48134887
| ResponseToolSearchOutputItem
48144888
| ResponseCompactionItem
48154889
| ResponseOutputItem.ImageGenerationCall
48164890
| ResponseCodeInterpreterToolCall
48174891
| ResponseOutputItem.LocalShellCall
4892+
| ResponseOutputItem.LocalShellCallOutput
48184893
| ResponseFunctionShellToolCall
48194894
| ResponseFunctionShellToolCallOutput
48204895
| ResponseApplyPatchToolCall
48214896
| ResponseApplyPatchToolCallOutput
48224897
| ResponseOutputItem.McpCall
48234898
| ResponseOutputItem.McpListTools
48244899
| ResponseOutputItem.McpApprovalRequest
4825-
| ResponseCustomToolCall;
4900+
| ResponseOutputItem.McpApprovalResponse
4901+
| ResponseCustomToolCall
4902+
| ResponseCustomToolCallOutputItem;
48264903

48274904
export namespace ResponseOutputItem {
48284905
/**
@@ -4917,6 +4994,31 @@ export namespace ResponseOutputItem {
49174994
}
49184995
}
49194996

4997+
/**
4998+
* The output of a local shell tool call.
4999+
*/
5000+
export interface LocalShellCallOutput {
5001+
/**
5002+
* The unique ID of the local shell tool call generated by the model.
5003+
*/
5004+
id: string;
5005+
5006+
/**
5007+
* A JSON string of the output of the local shell tool call.
5008+
*/
5009+
output: string;
5010+
5011+
/**
5012+
* The type of the local shell tool call output. Always `local_shell_call_output`.
5013+
*/
5014+
type: 'local_shell_call_output';
5015+
5016+
/**
5017+
* The status of the item. One of `in_progress`, `completed`, or `incomplete`.
5018+
*/
5019+
status?: 'in_progress' | 'completed' | 'incomplete' | null;
5020+
}
5021+
49205022
/**
49215023
* An invocation of a tool on an MCP server.
49225024
*/
@@ -5056,6 +5158,36 @@ export namespace ResponseOutputItem {
50565158
*/
50575159
type: 'mcp_approval_request';
50585160
}
5161+
5162+
/**
5163+
* A response to an MCP approval request.
5164+
*/
5165+
export interface McpApprovalResponse {
5166+
/**
5167+
* The unique ID of the approval response
5168+
*/
5169+
id: string;
5170+
5171+
/**
5172+
* The ID of the approval request being answered.
5173+
*/
5174+
approval_request_id: string;
5175+
5176+
/**
5177+
* Whether the request was approved.
5178+
*/
5179+
approve: boolean;
5180+
5181+
/**
5182+
* The type of the item. Always `mcp_approval_response`.
5183+
*/
5184+
type: 'mcp_approval_response';
5185+
5186+
/**
5187+
* Optional reason for the decision.
5188+
*/
5189+
reason?: string | null;
5190+
}
50595191
}
50605192

50615193
/**
@@ -7889,7 +8021,9 @@ export declare namespace Responses {
78898021
type ResponseCustomToolCall as ResponseCustomToolCall,
78908022
type ResponseCustomToolCallInputDeltaEvent as ResponseCustomToolCallInputDeltaEvent,
78918023
type ResponseCustomToolCallInputDoneEvent as ResponseCustomToolCallInputDoneEvent,
8024+
type ResponseCustomToolCallItem as ResponseCustomToolCallItem,
78928025
type ResponseCustomToolCallOutput as ResponseCustomToolCallOutput,
8026+
type ResponseCustomToolCallOutputItem as ResponseCustomToolCallOutputItem,
78938027
type ResponseError as ResponseError,
78948028
type ResponseErrorEvent as ResponseErrorEvent,
78958029
type ResponseFailedEvent as ResponseFailedEvent,

tests/responsesItems.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import OpenAI from 'openai/index';
22
const openai = new OpenAI({ apiKey: 'example-api-key' });
33

4+
function isInputCompatibleOutputItem(
5+
item: OpenAI.Responses.ResponseOutputItem,
6+
): item is Exclude<OpenAI.Responses.ResponseOutputItem, OpenAI.Responses.ResponseComputerToolCallOutputItem> {
7+
return item.type !== 'computer_call_output';
8+
}
9+
410
describe('responses item types', () => {
511
test('response output items are compatible with input items', async () => {
612
expect(true).toBe(true);
@@ -15,7 +21,7 @@ const unused = async () => {
1521
await openai.responses.create({
1622
model: 'gpt-5.1',
1723
// check type compatibility
18-
input: response.output,
24+
input: response.output.filter(isInputCompatibleOutputItem),
1925
});
2026
expect(true).toBe(true);
2127
};

0 commit comments

Comments
 (0)