Skip to content

Commit 6295339

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 5acfb76 commit 6295339

27 files changed

Lines changed: 4328 additions & 392 deletions

.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

openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.openai.models.conversations.Message
2929
import com.openai.models.responses.ResponseApplyPatchToolCall
3030
import com.openai.models.responses.ResponseApplyPatchToolCallOutput
3131
import com.openai.models.responses.ResponseCodeInterpreterToolCall
32+
import com.openai.models.responses.ResponseCompactionItem
3233
import com.openai.models.responses.ResponseComputerToolCall
3334
import com.openai.models.responses.ResponseComputerToolCallOutputItem
3435
import com.openai.models.responses.ResponseCustomToolCall
@@ -67,6 +68,7 @@ private constructor(
6768
private val toolSearchCall: ResponseToolSearchCall? = null,
6869
private val toolSearchOutput: ResponseToolSearchOutputItem? = null,
6970
private val reasoning: ResponseReasoningItem? = null,
71+
private val compaction: ResponseCompactionItem? = null,
7072
private val codeInterpreterCall: ResponseCodeInterpreterToolCall? = null,
7173
private val localShellCall: LocalShellCall? = null,
7274
private val localShellCallOutput: LocalShellCallOutput? = null,
@@ -137,6 +139,12 @@ private constructor(
137139
*/
138140
fun reasoning(): Optional<ResponseReasoningItem> = Optional.ofNullable(reasoning)
139141

142+
/**
143+
* A compaction item generated by the
144+
* [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
145+
*/
146+
fun compaction(): Optional<ResponseCompactionItem> = Optional.ofNullable(compaction)
147+
140148
/** A tool call to run code. */
141149
fun codeInterpreterCall(): Optional<ResponseCodeInterpreterToolCall> =
142150
Optional.ofNullable(codeInterpreterCall)
@@ -204,6 +212,8 @@ private constructor(
204212

205213
fun isReasoning(): Boolean = reasoning != null
206214

215+
fun isCompaction(): Boolean = compaction != null
216+
207217
fun isCodeInterpreterCall(): Boolean = codeInterpreterCall != null
208218

209219
fun isLocalShellCall(): Boolean = localShellCall != null
@@ -284,6 +294,12 @@ private constructor(
284294
*/
285295
fun asReasoning(): ResponseReasoningItem = reasoning.getOrThrow("reasoning")
286296

297+
/**
298+
* A compaction item generated by the
299+
* [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
300+
*/
301+
fun asCompaction(): ResponseCompactionItem = compaction.getOrThrow("compaction")
302+
287303
/** A tool call to run code. */
288304
fun asCodeInterpreterCall(): ResponseCodeInterpreterToolCall =
289305
codeInterpreterCall.getOrThrow("codeInterpreterCall")
@@ -345,6 +361,7 @@ private constructor(
345361
toolSearchCall != null -> visitor.visitToolSearchCall(toolSearchCall)
346362
toolSearchOutput != null -> visitor.visitToolSearchOutput(toolSearchOutput)
347363
reasoning != null -> visitor.visitReasoning(reasoning)
364+
compaction != null -> visitor.visitCompaction(compaction)
348365
codeInterpreterCall != null -> visitor.visitCodeInterpreterCall(codeInterpreterCall)
349366
localShellCall != null -> visitor.visitLocalShellCall(localShellCall)
350367
localShellCallOutput != null -> visitor.visitLocalShellCallOutput(localShellCallOutput)
@@ -418,6 +435,10 @@ private constructor(
418435
reasoning.validate()
419436
}
420437

438+
override fun visitCompaction(compaction: ResponseCompactionItem) {
439+
compaction.validate()
440+
}
441+
421442
override fun visitCodeInterpreterCall(
422443
codeInterpreterCall: ResponseCodeInterpreterToolCall
423444
) {
@@ -532,6 +553,9 @@ private constructor(
532553

533554
override fun visitReasoning(reasoning: ResponseReasoningItem) = reasoning.validity()
534555

556+
override fun visitCompaction(compaction: ResponseCompactionItem) =
557+
compaction.validity()
558+
535559
override fun visitCodeInterpreterCall(
536560
codeInterpreterCall: ResponseCodeInterpreterToolCall
537561
) = codeInterpreterCall.validity()
@@ -594,6 +618,7 @@ private constructor(
594618
toolSearchCall == other.toolSearchCall &&
595619
toolSearchOutput == other.toolSearchOutput &&
596620
reasoning == other.reasoning &&
621+
compaction == other.compaction &&
597622
codeInterpreterCall == other.codeInterpreterCall &&
598623
localShellCall == other.localShellCall &&
599624
localShellCallOutput == other.localShellCallOutput &&
@@ -622,6 +647,7 @@ private constructor(
622647
toolSearchCall,
623648
toolSearchOutput,
624649
reasoning,
650+
compaction,
625651
codeInterpreterCall,
626652
localShellCall,
627653
localShellCallOutput,
@@ -651,6 +677,7 @@ private constructor(
651677
toolSearchCall != null -> "ConversationItem{toolSearchCall=$toolSearchCall}"
652678
toolSearchOutput != null -> "ConversationItem{toolSearchOutput=$toolSearchOutput}"
653679
reasoning != null -> "ConversationItem{reasoning=$reasoning}"
680+
compaction != null -> "ConversationItem{compaction=$compaction}"
654681
codeInterpreterCall != null ->
655682
"ConversationItem{codeInterpreterCall=$codeInterpreterCall}"
656683
localShellCall != null -> "ConversationItem{localShellCall=$localShellCall}"
@@ -744,6 +771,14 @@ private constructor(
744771
@JvmStatic
745772
fun ofReasoning(reasoning: ResponseReasoningItem) = ConversationItem(reasoning = reasoning)
746773

774+
/**
775+
* A compaction item generated by the
776+
* [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
777+
*/
778+
@JvmStatic
779+
fun ofCompaction(compaction: ResponseCompactionItem) =
780+
ConversationItem(compaction = compaction)
781+
747782
/** A tool call to run code. */
748783
@JvmStatic
749784
fun ofCodeInterpreterCall(codeInterpreterCall: ResponseCodeInterpreterToolCall) =
@@ -864,6 +899,12 @@ private constructor(
864899
*/
865900
fun visitReasoning(reasoning: ResponseReasoningItem): T
866901

902+
/**
903+
* A compaction item generated by the
904+
* [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
905+
*/
906+
fun visitCompaction(compaction: ResponseCompactionItem): T
907+
867908
/** A tool call to run code. */
868909
fun visitCodeInterpreterCall(codeInterpreterCall: ResponseCodeInterpreterToolCall): T
869910

@@ -986,6 +1027,11 @@ private constructor(
9861027
ConversationItem(reasoning = it, _json = json)
9871028
} ?: ConversationItem(_json = json)
9881029
}
1030+
"compaction" -> {
1031+
return tryDeserialize(node, jacksonTypeRef<ResponseCompactionItem>())?.let {
1032+
ConversationItem(compaction = it, _json = json)
1033+
} ?: ConversationItem(_json = json)
1034+
}
9891035
"code_interpreter_call" -> {
9901036
return tryDeserialize(node, jacksonTypeRef<ResponseCodeInterpreterToolCall>())
9911037
?.let { ConversationItem(codeInterpreterCall = it, _json = json) }
@@ -1080,6 +1126,7 @@ private constructor(
10801126
value.toolSearchCall != null -> generator.writeObject(value.toolSearchCall)
10811127
value.toolSearchOutput != null -> generator.writeObject(value.toolSearchOutput)
10821128
value.reasoning != null -> generator.writeObject(value.reasoning)
1129+
value.compaction != null -> generator.writeObject(value.compaction)
10831130
value.codeInterpreterCall != null ->
10841131
generator.writeObject(value.codeInterpreterCall)
10851132
value.localShellCall != null -> generator.writeObject(value.localShellCall)

openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItemList.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import com.openai.models.conversations.Message
1818
import com.openai.models.responses.ResponseApplyPatchToolCall
1919
import com.openai.models.responses.ResponseApplyPatchToolCallOutput
2020
import com.openai.models.responses.ResponseCodeInterpreterToolCall
21+
import com.openai.models.responses.ResponseCompactionItem
2122
import com.openai.models.responses.ResponseComputerToolCall
2223
import com.openai.models.responses.ResponseComputerToolCallOutputItem
2324
import com.openai.models.responses.ResponseCustomToolCall
@@ -259,6 +260,10 @@ private constructor(
259260
fun addData(reasoning: ResponseReasoningItem) =
260261
addData(ConversationItem.ofReasoning(reasoning))
261262

263+
/** Alias for calling [addData] with `ConversationItem.ofCompaction(compaction)`. */
264+
fun addData(compaction: ResponseCompactionItem) =
265+
addData(ConversationItem.ofCompaction(compaction))
266+
262267
/**
263268
* Alias for calling [addData] with
264269
* `ConversationItem.ofCodeInterpreterCall(codeInterpreterCall)`.

openai-java-core/src/main/kotlin/com/openai/models/responses/CompactedResponse.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ private constructor(
243243
fun addOutput(functionCall: ResponseFunctionToolCall) =
244244
addOutput(ResponseOutputItem.ofFunctionCall(functionCall))
245245

246+
/**
247+
* Alias for calling [addOutput] with
248+
* `ResponseOutputItem.ofFunctionCallOutput(functionCallOutput)`.
249+
*/
250+
fun addOutput(functionCallOutput: ResponseFunctionToolCallOutputItem) =
251+
addOutput(ResponseOutputItem.ofFunctionCallOutput(functionCallOutput))
252+
246253
/**
247254
* Alias for calling [addOutput] with `ResponseOutputItem.ofWebSearchCall(webSearchCall)`.
248255
*/
@@ -253,6 +260,13 @@ private constructor(
253260
fun addOutput(computerCall: ResponseComputerToolCall) =
254261
addOutput(ResponseOutputItem.ofComputerCall(computerCall))
255262

263+
/**
264+
* Alias for calling [addOutput] with
265+
* `ResponseOutputItem.ofComputerCallOutput(computerCallOutput)`.
266+
*/
267+
fun addOutput(computerCallOutput: ResponseComputerToolCallOutputItem) =
268+
addOutput(ResponseOutputItem.ofComputerCallOutput(computerCallOutput))
269+
256270
/** Alias for calling [addOutput] with `ResponseOutputItem.ofReasoning(reasoning)`. */
257271
fun addOutput(reasoning: ResponseReasoningItem) =
258272
addOutput(ResponseOutputItem.ofReasoning(reasoning))
@@ -294,6 +308,13 @@ private constructor(
294308
fun addOutput(localShellCall: ResponseOutputItem.LocalShellCall) =
295309
addOutput(ResponseOutputItem.ofLocalShellCall(localShellCall))
296310

311+
/**
312+
* Alias for calling [addOutput] with
313+
* `ResponseOutputItem.ofLocalShellCallOutput(localShellCallOutput)`.
314+
*/
315+
fun addOutput(localShellCallOutput: ResponseOutputItem.LocalShellCallOutput) =
316+
addOutput(ResponseOutputItem.ofLocalShellCallOutput(localShellCallOutput))
317+
297318
/** Alias for calling [addOutput] with `ResponseOutputItem.ofShellCall(shellCall)`. */
298319
fun addOutput(shellCall: ResponseFunctionShellToolCall) =
299320
addOutput(ResponseOutputItem.ofShellCall(shellCall))
@@ -333,12 +354,26 @@ private constructor(
333354
fun addOutput(mcpApprovalRequest: ResponseOutputItem.McpApprovalRequest) =
334355
addOutput(ResponseOutputItem.ofMcpApprovalRequest(mcpApprovalRequest))
335356

357+
/**
358+
* Alias for calling [addOutput] with
359+
* `ResponseOutputItem.ofMcpApprovalResponse(mcpApprovalResponse)`.
360+
*/
361+
fun addOutput(mcpApprovalResponse: ResponseOutputItem.McpApprovalResponse) =
362+
addOutput(ResponseOutputItem.ofMcpApprovalResponse(mcpApprovalResponse))
363+
336364
/**
337365
* Alias for calling [addOutput] with `ResponseOutputItem.ofCustomToolCall(customToolCall)`.
338366
*/
339367
fun addOutput(customToolCall: ResponseCustomToolCall) =
340368
addOutput(ResponseOutputItem.ofCustomToolCall(customToolCall))
341369

370+
/**
371+
* Alias for calling [addOutput] with
372+
* `ResponseOutputItem.ofCustomToolCallOutput(customToolCallOutput)`.
373+
*/
374+
fun addOutput(customToolCallOutput: ResponseCustomToolCallOutputItem) =
375+
addOutput(ResponseOutputItem.ofCustomToolCallOutput(customToolCallOutput))
376+
342377
/**
343378
* Token accounting for the compaction pass, including cached, reasoning, and total tokens.
344379
*/

openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,13 @@ private constructor(
11001100
fun addOutput(functionCall: ResponseFunctionToolCall) =
11011101
addOutput(ResponseOutputItem.ofFunctionCall(functionCall))
11021102

1103+
/**
1104+
* Alias for calling [addOutput] with
1105+
* `ResponseOutputItem.ofFunctionCallOutput(functionCallOutput)`.
1106+
*/
1107+
fun addOutput(functionCallOutput: ResponseFunctionToolCallOutputItem) =
1108+
addOutput(ResponseOutputItem.ofFunctionCallOutput(functionCallOutput))
1109+
11031110
/**
11041111
* Alias for calling [addOutput] with `ResponseOutputItem.ofWebSearchCall(webSearchCall)`.
11051112
*/
@@ -1110,6 +1117,13 @@ private constructor(
11101117
fun addOutput(computerCall: ResponseComputerToolCall) =
11111118
addOutput(ResponseOutputItem.ofComputerCall(computerCall))
11121119

1120+
/**
1121+
* Alias for calling [addOutput] with
1122+
* `ResponseOutputItem.ofComputerCallOutput(computerCallOutput)`.
1123+
*/
1124+
fun addOutput(computerCallOutput: ResponseComputerToolCallOutputItem) =
1125+
addOutput(ResponseOutputItem.ofComputerCallOutput(computerCallOutput))
1126+
11131127
/** Alias for calling [addOutput] with `ResponseOutputItem.ofReasoning(reasoning)`. */
11141128
fun addOutput(reasoning: ResponseReasoningItem) =
11151129
addOutput(ResponseOutputItem.ofReasoning(reasoning))
@@ -1151,6 +1165,13 @@ private constructor(
11511165
fun addOutput(localShellCall: ResponseOutputItem.LocalShellCall) =
11521166
addOutput(ResponseOutputItem.ofLocalShellCall(localShellCall))
11531167

1168+
/**
1169+
* Alias for calling [addOutput] with
1170+
* `ResponseOutputItem.ofLocalShellCallOutput(localShellCallOutput)`.
1171+
*/
1172+
fun addOutput(localShellCallOutput: ResponseOutputItem.LocalShellCallOutput) =
1173+
addOutput(ResponseOutputItem.ofLocalShellCallOutput(localShellCallOutput))
1174+
11541175
/** Alias for calling [addOutput] with `ResponseOutputItem.ofShellCall(shellCall)`. */
11551176
fun addOutput(shellCall: ResponseFunctionShellToolCall) =
11561177
addOutput(ResponseOutputItem.ofShellCall(shellCall))
@@ -1190,12 +1211,26 @@ private constructor(
11901211
fun addOutput(mcpApprovalRequest: ResponseOutputItem.McpApprovalRequest) =
11911212
addOutput(ResponseOutputItem.ofMcpApprovalRequest(mcpApprovalRequest))
11921213

1214+
/**
1215+
* Alias for calling [addOutput] with
1216+
* `ResponseOutputItem.ofMcpApprovalResponse(mcpApprovalResponse)`.
1217+
*/
1218+
fun addOutput(mcpApprovalResponse: ResponseOutputItem.McpApprovalResponse) =
1219+
addOutput(ResponseOutputItem.ofMcpApprovalResponse(mcpApprovalResponse))
1220+
11931221
/**
11941222
* Alias for calling [addOutput] with `ResponseOutputItem.ofCustomToolCall(customToolCall)`.
11951223
*/
11961224
fun addOutput(customToolCall: ResponseCustomToolCall) =
11971225
addOutput(ResponseOutputItem.ofCustomToolCall(customToolCall))
11981226

1227+
/**
1228+
* Alias for calling [addOutput] with
1229+
* `ResponseOutputItem.ofCustomToolCallOutput(customToolCallOutput)`.
1230+
*/
1231+
fun addOutput(customToolCallOutput: ResponseCustomToolCallOutputItem) =
1232+
addOutput(ResponseOutputItem.ofCustomToolCallOutput(customToolCallOutput))
1233+
11991234
/** Whether to allow the model to run tool calls in parallel. */
12001235
fun parallelToolCalls(parallelToolCalls: Boolean) =
12011236
parallelToolCalls(JsonField.of(parallelToolCalls))

0 commit comments

Comments
 (0)