diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 127ac87b..6a37fe2d 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "4.0.0"
+ ".": "4.0.1"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 10c939b2..27f2ffc6 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 118
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-49233088b5e73dbb96bf7af27be3d4547632e3db1c2b00f14184900613325bbc.yml
-openapi_spec_hash: b34f14b141d5019244112901c5c7c2d8
-config_hash: 94e9ba08201c3d1ca46e093e6a0138fa
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-e205b1f2da6a1f2caa229efa9ede63f2d3d2fedeeb2dd6ed3d880bafdcb0ab88.yml
+openapi_spec_hash: c8aee2469a749f6a838b40c57e4b7b06
+config_hash: 45dcba51451ba532959c020a0ddbf23c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0b2d01fb..b3d2db44 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## 4.0.1 (2025-10-01)
+
+Full Changelog: [v4.0.0...v4.0.1](https://github.com/openai/openai-java/compare/v4.0.0...v4.0.1)
+
+### Bug Fixes
+
+* **api:** add status, approval_request_id to MCP tool call ([56ed867](https://github.com/openai/openai-java/commit/56ed86777a63590b79559e850ce1c34d0c0b9af0))
+
## 4.0.0 (2025-09-30)
Full Changelog: [v3.7.1...v4.0.0](https://github.com/openai/openai-java/compare/v3.7.1...v4.0.0)
diff --git a/README.md b/README.md
index 9518af40..84e22df1 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/com.openai/openai-java/4.0.0)
-[](https://javadoc.io/doc/com.openai/openai-java/4.0.0)
+[](https://central.sonatype.com/artifact/com.openai/openai-java/4.0.1)
+[](https://javadoc.io/doc/com.openai/openai-java/4.0.1)
@@ -11,7 +11,7 @@ The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https://
-The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.0.0).
+The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.0.1).
@@ -24,7 +24,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
### Gradle
```kotlin
-implementation("com.openai:openai-java:4.0.0")
+implementation("com.openai:openai-java:4.0.1")
```
### Maven
@@ -33,7 +33,7 @@ implementation("com.openai:openai-java:4.0.0")
com.openai
openai-java
- 4.0.0
+ 4.0.1
```
@@ -1342,7 +1342,7 @@ If you're using Spring Boot, then you can use the SDK's [Spring Boot starter](ht
#### Gradle
```kotlin
-implementation("com.openai:openai-java-spring-boot-starter:4.0.0")
+implementation("com.openai:openai-java-spring-boot-starter:4.0.1")
```
#### Maven
@@ -1351,7 +1351,7 @@ implementation("com.openai:openai-java-spring-boot-starter:4.0.0")
com.openai
openai-java-spring-boot-starter
- 4.0.0
+ 4.0.1
```
diff --git a/build.gradle.kts b/build.gradle.kts
index 56b2996d..3230d8a3 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "com.openai"
- version = "4.0.0" // x-release-please-version
+ version = "4.0.1" // x-release-please-version
}
subprojects {
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt
index c9df30f5..61dfebd2 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt
@@ -3922,8 +3922,10 @@ private constructor(
private val name: JsonField,
private val serverLabel: JsonField,
private val type: JsonValue,
+ private val approvalRequestId: JsonField,
private val error: JsonField,
private val output: JsonField,
+ private val status: JsonField,
private val additionalProperties: MutableMap,
) {
@@ -3938,9 +3940,24 @@ private constructor(
@ExcludeMissing
serverLabel: JsonField = JsonMissing.of(),
@JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
+ @JsonProperty("approval_request_id")
+ @ExcludeMissing
+ approvalRequestId: JsonField = JsonMissing.of(),
@JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(),
@JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(),
- ) : this(id, arguments, name, serverLabel, type, error, output, mutableMapOf())
+ @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(),
+ ) : this(
+ id,
+ arguments,
+ name,
+ serverLabel,
+ type,
+ approvalRequestId,
+ error,
+ output,
+ status,
+ mutableMapOf(),
+ )
/**
* The unique ID of the tool call.
@@ -3987,6 +4004,17 @@ private constructor(
*/
@JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
+ /**
+ * Unique identifier for the MCP tool call approval request. Include this value in a
+ * subsequent `mcp_approval_response` input to approve or reject the corresponding tool
+ * call.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun approvalRequestId(): Optional =
+ approvalRequestId.getOptional("approval_request_id")
+
/**
* The error from the tool call, if any.
*
@@ -4003,6 +4031,15 @@ private constructor(
*/
fun output(): Optional = output.getOptional("output")
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`,
+ * or `failed`.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun status(): Optional = status.getOptional("status")
+
/**
* Returns the raw JSON value of [id].
*
@@ -4033,6 +4070,16 @@ private constructor(
@ExcludeMissing
fun _serverLabel(): JsonField = serverLabel
+ /**
+ * Returns the raw JSON value of [approvalRequestId].
+ *
+ * Unlike [approvalRequestId], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("approval_request_id")
+ @ExcludeMissing
+ fun _approvalRequestId(): JsonField = approvalRequestId
+
/**
* Returns the raw JSON value of [error].
*
@@ -4047,6 +4094,13 @@ private constructor(
*/
@JsonProperty("output") @ExcludeMissing fun _output(): JsonField = output
+ /**
+ * Returns the raw JSON value of [status].
+ *
+ * Unlike [status], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status
+
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
@@ -4083,8 +4137,10 @@ private constructor(
private var name: JsonField? = null
private var serverLabel: JsonField? = null
private var type: JsonValue = JsonValue.from("mcp_call")
+ private var approvalRequestId: JsonField = JsonMissing.of()
private var error: JsonField = JsonMissing.of()
private var output: JsonField = JsonMissing.of()
+ private var status: JsonField = JsonMissing.of()
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -4094,8 +4150,10 @@ private constructor(
name = mcpCall.name
serverLabel = mcpCall.serverLabel
type = mcpCall.type
+ approvalRequestId = mcpCall.approvalRequestId
error = mcpCall.error
output = mcpCall.output
+ status = mcpCall.status
additionalProperties = mcpCall.additionalProperties.toMutableMap()
}
@@ -4163,6 +4221,31 @@ private constructor(
*/
fun type(type: JsonValue) = apply { this.type = type }
+ /**
+ * Unique identifier for the MCP tool call approval request. Include this value in a
+ * subsequent `mcp_approval_response` input to approve or reject the corresponding tool
+ * call.
+ */
+ fun approvalRequestId(approvalRequestId: String?) =
+ approvalRequestId(JsonField.ofNullable(approvalRequestId))
+
+ /**
+ * Alias for calling [Builder.approvalRequestId] with `approvalRequestId.orElse(null)`.
+ */
+ fun approvalRequestId(approvalRequestId: Optional) =
+ approvalRequestId(approvalRequestId.getOrNull())
+
+ /**
+ * Sets [Builder.approvalRequestId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.approvalRequestId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun approvalRequestId(approvalRequestId: JsonField) = apply {
+ this.approvalRequestId = approvalRequestId
+ }
+
/** The error from the tool call, if any. */
fun error(error: String?) = error(JsonField.ofNullable(error))
@@ -4193,6 +4276,21 @@ private constructor(
*/
fun output(output: JsonField) = apply { this.output = output }
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
+ * `calling`, or `failed`.
+ */
+ fun status(status: Status) = status(JsonField.of(status))
+
+ /**
+ * Sets [Builder.status] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.status] with a well-typed [Status] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun status(status: JsonField) = apply { this.status = status }
+
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
@@ -4234,8 +4332,10 @@ private constructor(
checkRequired("name", name),
checkRequired("serverLabel", serverLabel),
type,
+ approvalRequestId,
error,
output,
+ status,
additionalProperties.toMutableMap(),
)
}
@@ -4256,8 +4356,10 @@ private constructor(
throw OpenAIInvalidDataException("'type' is invalid, received $it")
}
}
+ approvalRequestId()
error()
output()
+ status().ifPresent { it.validate() }
validated = true
}
@@ -4282,8 +4384,161 @@ private constructor(
(if (name.asKnown().isPresent) 1 else 0) +
(if (serverLabel.asKnown().isPresent) 1 else 0) +
type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } +
+ (if (approvalRequestId.asKnown().isPresent) 1 else 0) +
(if (error.asKnown().isPresent) 1 else 0) +
- (if (output.asKnown().isPresent) 1 else 0)
+ (if (output.asKnown().isPresent) 1 else 0) +
+ (status.asKnown().getOrNull()?.validity() ?: 0)
+
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`,
+ * or `failed`.
+ */
+ class Status @JsonCreator private constructor(private val value: JsonField) : Enum {
+
+ /**
+ * Returns this class instance's raw value.
+ *
+ * This is usually only useful if this instance was deserialized from data that doesn't
+ * match any known member, and you want to know that value. For example, if the SDK is
+ * on an older version than the API, then the API may respond with new members that the
+ * SDK is unaware of.
+ */
+ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
+
+ companion object {
+
+ @JvmField val IN_PROGRESS = of("in_progress")
+
+ @JvmField val COMPLETED = of("completed")
+
+ @JvmField val INCOMPLETE = of("incomplete")
+
+ @JvmField val CALLING = of("calling")
+
+ @JvmField val FAILED = of("failed")
+
+ @JvmStatic fun of(value: String) = Status(JsonField.of(value))
+ }
+
+ /** An enum containing [Status]'s known values. */
+ enum class Known {
+ IN_PROGRESS,
+ COMPLETED,
+ INCOMPLETE,
+ CALLING,
+ FAILED,
+ }
+
+ /**
+ * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Status] can contain an unknown value in a couple of cases:
+ * - It was deserialized from data that doesn't match any known member. For example, if
+ * the SDK is on an older version than the API, then the API may respond with new
+ * members that the SDK is unaware of.
+ * - It was constructed with an arbitrary value using the [of] method.
+ */
+ enum class Value {
+ IN_PROGRESS,
+ COMPLETED,
+ INCOMPLETE,
+ CALLING,
+ FAILED,
+ /**
+ * An enum member indicating that [Status] was instantiated with an unknown value.
+ */
+ _UNKNOWN,
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value, or
+ * [Value._UNKNOWN] if the class was instantiated with an unknown value.
+ *
+ * Use the [known] method instead if you're certain the value is always known or if you
+ * want to throw for the unknown case.
+ */
+ fun value(): Value =
+ when (this) {
+ IN_PROGRESS -> Value.IN_PROGRESS
+ COMPLETED -> Value.COMPLETED
+ INCOMPLETE -> Value.INCOMPLETE
+ CALLING -> Value.CALLING
+ FAILED -> Value.FAILED
+ else -> Value._UNKNOWN
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value.
+ *
+ * Use the [value] method instead if you're uncertain the value is always known and
+ * don't want to throw for the unknown case.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ IN_PROGRESS -> Known.IN_PROGRESS
+ COMPLETED -> Known.COMPLETED
+ INCOMPLETE -> Known.INCOMPLETE
+ CALLING -> Known.CALLING
+ FAILED -> Known.FAILED
+ else -> throw OpenAIInvalidDataException("Unknown Status: $value")
+ }
+
+ /**
+ * Returns this class instance's primitive wire representation.
+ *
+ * This differs from the [toString] method because that method is primarily for
+ * debugging and generally doesn't throw.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ OpenAIInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Status = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: OpenAIInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Status && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
override fun equals(other: Any?): Boolean {
if (this === other) {
@@ -4296,8 +4551,10 @@ private constructor(
name == other.name &&
serverLabel == other.serverLabel &&
type == other.type &&
+ approvalRequestId == other.approvalRequestId &&
error == other.error &&
output == other.output &&
+ status == other.status &&
additionalProperties == other.additionalProperties
}
@@ -4308,8 +4565,10 @@ private constructor(
name,
serverLabel,
type,
+ approvalRequestId,
error,
output,
+ status,
additionalProperties,
)
}
@@ -4317,6 +4576,6 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "McpCall{id=$id, arguments=$arguments, name=$name, serverLabel=$serverLabel, type=$type, error=$error, output=$output, additionalProperties=$additionalProperties}"
+ "McpCall{id=$id, arguments=$arguments, name=$name, serverLabel=$serverLabel, type=$type, approvalRequestId=$approvalRequestId, error=$error, output=$output, status=$status, additionalProperties=$additionalProperties}"
}
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt
index 6f917a4f..030624ae 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt
@@ -6309,8 +6309,10 @@ private constructor(
private val name: JsonField,
private val serverLabel: JsonField,
private val type: JsonValue,
+ private val approvalRequestId: JsonField,
private val error: JsonField,
private val output: JsonField,
+ private val status: JsonField,
private val additionalProperties: MutableMap,
) {
@@ -6325,9 +6327,24 @@ private constructor(
@ExcludeMissing
serverLabel: JsonField = JsonMissing.of(),
@JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
+ @JsonProperty("approval_request_id")
+ @ExcludeMissing
+ approvalRequestId: JsonField = JsonMissing.of(),
@JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(),
@JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(),
- ) : this(id, arguments, name, serverLabel, type, error, output, mutableMapOf())
+ @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(),
+ ) : this(
+ id,
+ arguments,
+ name,
+ serverLabel,
+ type,
+ approvalRequestId,
+ error,
+ output,
+ status,
+ mutableMapOf(),
+ )
/**
* The unique ID of the tool call.
@@ -6374,6 +6391,17 @@ private constructor(
*/
@JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
+ /**
+ * Unique identifier for the MCP tool call approval request. Include this value in a
+ * subsequent `mcp_approval_response` input to approve or reject the corresponding tool
+ * call.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun approvalRequestId(): Optional =
+ approvalRequestId.getOptional("approval_request_id")
+
/**
* The error from the tool call, if any.
*
@@ -6390,6 +6418,15 @@ private constructor(
*/
fun output(): Optional = output.getOptional("output")
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`,
+ * or `failed`.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun status(): Optional = status.getOptional("status")
+
/**
* Returns the raw JSON value of [id].
*
@@ -6420,6 +6457,16 @@ private constructor(
@ExcludeMissing
fun _serverLabel(): JsonField = serverLabel
+ /**
+ * Returns the raw JSON value of [approvalRequestId].
+ *
+ * Unlike [approvalRequestId], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("approval_request_id")
+ @ExcludeMissing
+ fun _approvalRequestId(): JsonField = approvalRequestId
+
/**
* Returns the raw JSON value of [error].
*
@@ -6434,6 +6481,13 @@ private constructor(
*/
@JsonProperty("output") @ExcludeMissing fun _output(): JsonField = output
+ /**
+ * Returns the raw JSON value of [status].
+ *
+ * Unlike [status], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status
+
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
@@ -6470,8 +6524,10 @@ private constructor(
private var name: JsonField? = null
private var serverLabel: JsonField? = null
private var type: JsonValue = JsonValue.from("mcp_call")
+ private var approvalRequestId: JsonField = JsonMissing.of()
private var error: JsonField = JsonMissing.of()
private var output: JsonField = JsonMissing.of()
+ private var status: JsonField = JsonMissing.of()
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -6481,8 +6537,10 @@ private constructor(
name = mcpCall.name
serverLabel = mcpCall.serverLabel
type = mcpCall.type
+ approvalRequestId = mcpCall.approvalRequestId
error = mcpCall.error
output = mcpCall.output
+ status = mcpCall.status
additionalProperties = mcpCall.additionalProperties.toMutableMap()
}
@@ -6550,6 +6608,31 @@ private constructor(
*/
fun type(type: JsonValue) = apply { this.type = type }
+ /**
+ * Unique identifier for the MCP tool call approval request. Include this value in a
+ * subsequent `mcp_approval_response` input to approve or reject the corresponding tool
+ * call.
+ */
+ fun approvalRequestId(approvalRequestId: String?) =
+ approvalRequestId(JsonField.ofNullable(approvalRequestId))
+
+ /**
+ * Alias for calling [Builder.approvalRequestId] with `approvalRequestId.orElse(null)`.
+ */
+ fun approvalRequestId(approvalRequestId: Optional) =
+ approvalRequestId(approvalRequestId.getOrNull())
+
+ /**
+ * Sets [Builder.approvalRequestId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.approvalRequestId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun approvalRequestId(approvalRequestId: JsonField) = apply {
+ this.approvalRequestId = approvalRequestId
+ }
+
/** The error from the tool call, if any. */
fun error(error: String?) = error(JsonField.ofNullable(error))
@@ -6580,6 +6663,21 @@ private constructor(
*/
fun output(output: JsonField) = apply { this.output = output }
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
+ * `calling`, or `failed`.
+ */
+ fun status(status: Status) = status(JsonField.of(status))
+
+ /**
+ * Sets [Builder.status] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.status] with a well-typed [Status] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun status(status: JsonField) = apply { this.status = status }
+
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
@@ -6621,8 +6719,10 @@ private constructor(
checkRequired("name", name),
checkRequired("serverLabel", serverLabel),
type,
+ approvalRequestId,
error,
output,
+ status,
additionalProperties.toMutableMap(),
)
}
@@ -6643,8 +6743,10 @@ private constructor(
throw OpenAIInvalidDataException("'type' is invalid, received $it")
}
}
+ approvalRequestId()
error()
output()
+ status().ifPresent { it.validate() }
validated = true
}
@@ -6669,8 +6771,161 @@ private constructor(
(if (name.asKnown().isPresent) 1 else 0) +
(if (serverLabel.asKnown().isPresent) 1 else 0) +
type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } +
+ (if (approvalRequestId.asKnown().isPresent) 1 else 0) +
(if (error.asKnown().isPresent) 1 else 0) +
- (if (output.asKnown().isPresent) 1 else 0)
+ (if (output.asKnown().isPresent) 1 else 0) +
+ (status.asKnown().getOrNull()?.validity() ?: 0)
+
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`,
+ * or `failed`.
+ */
+ class Status @JsonCreator private constructor(private val value: JsonField) : Enum {
+
+ /**
+ * Returns this class instance's raw value.
+ *
+ * This is usually only useful if this instance was deserialized from data that doesn't
+ * match any known member, and you want to know that value. For example, if the SDK is
+ * on an older version than the API, then the API may respond with new members that the
+ * SDK is unaware of.
+ */
+ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
+
+ companion object {
+
+ @JvmField val IN_PROGRESS = of("in_progress")
+
+ @JvmField val COMPLETED = of("completed")
+
+ @JvmField val INCOMPLETE = of("incomplete")
+
+ @JvmField val CALLING = of("calling")
+
+ @JvmField val FAILED = of("failed")
+
+ @JvmStatic fun of(value: String) = Status(JsonField.of(value))
+ }
+
+ /** An enum containing [Status]'s known values. */
+ enum class Known {
+ IN_PROGRESS,
+ COMPLETED,
+ INCOMPLETE,
+ CALLING,
+ FAILED,
+ }
+
+ /**
+ * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Status] can contain an unknown value in a couple of cases:
+ * - It was deserialized from data that doesn't match any known member. For example, if
+ * the SDK is on an older version than the API, then the API may respond with new
+ * members that the SDK is unaware of.
+ * - It was constructed with an arbitrary value using the [of] method.
+ */
+ enum class Value {
+ IN_PROGRESS,
+ COMPLETED,
+ INCOMPLETE,
+ CALLING,
+ FAILED,
+ /**
+ * An enum member indicating that [Status] was instantiated with an unknown value.
+ */
+ _UNKNOWN,
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value, or
+ * [Value._UNKNOWN] if the class was instantiated with an unknown value.
+ *
+ * Use the [known] method instead if you're certain the value is always known or if you
+ * want to throw for the unknown case.
+ */
+ fun value(): Value =
+ when (this) {
+ IN_PROGRESS -> Value.IN_PROGRESS
+ COMPLETED -> Value.COMPLETED
+ INCOMPLETE -> Value.INCOMPLETE
+ CALLING -> Value.CALLING
+ FAILED -> Value.FAILED
+ else -> Value._UNKNOWN
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value.
+ *
+ * Use the [value] method instead if you're uncertain the value is always known and
+ * don't want to throw for the unknown case.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ IN_PROGRESS -> Known.IN_PROGRESS
+ COMPLETED -> Known.COMPLETED
+ INCOMPLETE -> Known.INCOMPLETE
+ CALLING -> Known.CALLING
+ FAILED -> Known.FAILED
+ else -> throw OpenAIInvalidDataException("Unknown Status: $value")
+ }
+
+ /**
+ * Returns this class instance's primitive wire representation.
+ *
+ * This differs from the [toString] method because that method is primarily for
+ * debugging and generally doesn't throw.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ OpenAIInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Status = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: OpenAIInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Status && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
override fun equals(other: Any?): Boolean {
if (this === other) {
@@ -6683,8 +6938,10 @@ private constructor(
name == other.name &&
serverLabel == other.serverLabel &&
type == other.type &&
+ approvalRequestId == other.approvalRequestId &&
error == other.error &&
output == other.output &&
+ status == other.status &&
additionalProperties == other.additionalProperties
}
@@ -6695,8 +6952,10 @@ private constructor(
name,
serverLabel,
type,
+ approvalRequestId,
error,
output,
+ status,
additionalProperties,
)
}
@@ -6704,7 +6963,7 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "McpCall{id=$id, arguments=$arguments, name=$name, serverLabel=$serverLabel, type=$type, error=$error, output=$output, additionalProperties=$additionalProperties}"
+ "McpCall{id=$id, arguments=$arguments, name=$name, serverLabel=$serverLabel, type=$type, approvalRequestId=$approvalRequestId, error=$error, output=$output, status=$status, additionalProperties=$additionalProperties}"
}
/** An internal identifier for an item to reference. */
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseItem.kt
index 31bed672..73c4b4e3 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseItem.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseItem.kt
@@ -3839,8 +3839,10 @@ private constructor(
private val name: JsonField,
private val serverLabel: JsonField,
private val type: JsonValue,
+ private val approvalRequestId: JsonField,
private val error: JsonField,
private val output: JsonField,
+ private val status: JsonField,
private val additionalProperties: MutableMap,
) {
@@ -3855,9 +3857,24 @@ private constructor(
@ExcludeMissing
serverLabel: JsonField = JsonMissing.of(),
@JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
+ @JsonProperty("approval_request_id")
+ @ExcludeMissing
+ approvalRequestId: JsonField = JsonMissing.of(),
@JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(),
@JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(),
- ) : this(id, arguments, name, serverLabel, type, error, output, mutableMapOf())
+ @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(),
+ ) : this(
+ id,
+ arguments,
+ name,
+ serverLabel,
+ type,
+ approvalRequestId,
+ error,
+ output,
+ status,
+ mutableMapOf(),
+ )
/**
* The unique ID of the tool call.
@@ -3904,6 +3921,17 @@ private constructor(
*/
@JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
+ /**
+ * Unique identifier for the MCP tool call approval request. Include this value in a
+ * subsequent `mcp_approval_response` input to approve or reject the corresponding tool
+ * call.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun approvalRequestId(): Optional =
+ approvalRequestId.getOptional("approval_request_id")
+
/**
* The error from the tool call, if any.
*
@@ -3920,6 +3948,15 @@ private constructor(
*/
fun output(): Optional = output.getOptional("output")
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`,
+ * or `failed`.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun status(): Optional = status.getOptional("status")
+
/**
* Returns the raw JSON value of [id].
*
@@ -3950,6 +3987,16 @@ private constructor(
@ExcludeMissing
fun _serverLabel(): JsonField = serverLabel
+ /**
+ * Returns the raw JSON value of [approvalRequestId].
+ *
+ * Unlike [approvalRequestId], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("approval_request_id")
+ @ExcludeMissing
+ fun _approvalRequestId(): JsonField = approvalRequestId
+
/**
* Returns the raw JSON value of [error].
*
@@ -3964,6 +4011,13 @@ private constructor(
*/
@JsonProperty("output") @ExcludeMissing fun _output(): JsonField = output
+ /**
+ * Returns the raw JSON value of [status].
+ *
+ * Unlike [status], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status
+
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
@@ -4000,8 +4054,10 @@ private constructor(
private var name: JsonField? = null
private var serverLabel: JsonField? = null
private var type: JsonValue = JsonValue.from("mcp_call")
+ private var approvalRequestId: JsonField = JsonMissing.of()
private var error: JsonField = JsonMissing.of()
private var output: JsonField = JsonMissing.of()
+ private var status: JsonField = JsonMissing.of()
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -4011,8 +4067,10 @@ private constructor(
name = mcpCall.name
serverLabel = mcpCall.serverLabel
type = mcpCall.type
+ approvalRequestId = mcpCall.approvalRequestId
error = mcpCall.error
output = mcpCall.output
+ status = mcpCall.status
additionalProperties = mcpCall.additionalProperties.toMutableMap()
}
@@ -4080,6 +4138,31 @@ private constructor(
*/
fun type(type: JsonValue) = apply { this.type = type }
+ /**
+ * Unique identifier for the MCP tool call approval request. Include this value in a
+ * subsequent `mcp_approval_response` input to approve or reject the corresponding tool
+ * call.
+ */
+ fun approvalRequestId(approvalRequestId: String?) =
+ approvalRequestId(JsonField.ofNullable(approvalRequestId))
+
+ /**
+ * Alias for calling [Builder.approvalRequestId] with `approvalRequestId.orElse(null)`.
+ */
+ fun approvalRequestId(approvalRequestId: Optional) =
+ approvalRequestId(approvalRequestId.getOrNull())
+
+ /**
+ * Sets [Builder.approvalRequestId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.approvalRequestId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun approvalRequestId(approvalRequestId: JsonField) = apply {
+ this.approvalRequestId = approvalRequestId
+ }
+
/** The error from the tool call, if any. */
fun error(error: String?) = error(JsonField.ofNullable(error))
@@ -4110,6 +4193,21 @@ private constructor(
*/
fun output(output: JsonField) = apply { this.output = output }
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
+ * `calling`, or `failed`.
+ */
+ fun status(status: Status) = status(JsonField.of(status))
+
+ /**
+ * Sets [Builder.status] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.status] with a well-typed [Status] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun status(status: JsonField) = apply { this.status = status }
+
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
@@ -4151,8 +4249,10 @@ private constructor(
checkRequired("name", name),
checkRequired("serverLabel", serverLabel),
type,
+ approvalRequestId,
error,
output,
+ status,
additionalProperties.toMutableMap(),
)
}
@@ -4173,8 +4273,10 @@ private constructor(
throw OpenAIInvalidDataException("'type' is invalid, received $it")
}
}
+ approvalRequestId()
error()
output()
+ status().ifPresent { it.validate() }
validated = true
}
@@ -4199,8 +4301,161 @@ private constructor(
(if (name.asKnown().isPresent) 1 else 0) +
(if (serverLabel.asKnown().isPresent) 1 else 0) +
type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } +
+ (if (approvalRequestId.asKnown().isPresent) 1 else 0) +
(if (error.asKnown().isPresent) 1 else 0) +
- (if (output.asKnown().isPresent) 1 else 0)
+ (if (output.asKnown().isPresent) 1 else 0) +
+ (status.asKnown().getOrNull()?.validity() ?: 0)
+
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`,
+ * or `failed`.
+ */
+ class Status @JsonCreator private constructor(private val value: JsonField) : Enum {
+
+ /**
+ * Returns this class instance's raw value.
+ *
+ * This is usually only useful if this instance was deserialized from data that doesn't
+ * match any known member, and you want to know that value. For example, if the SDK is
+ * on an older version than the API, then the API may respond with new members that the
+ * SDK is unaware of.
+ */
+ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
+
+ companion object {
+
+ @JvmField val IN_PROGRESS = of("in_progress")
+
+ @JvmField val COMPLETED = of("completed")
+
+ @JvmField val INCOMPLETE = of("incomplete")
+
+ @JvmField val CALLING = of("calling")
+
+ @JvmField val FAILED = of("failed")
+
+ @JvmStatic fun of(value: String) = Status(JsonField.of(value))
+ }
+
+ /** An enum containing [Status]'s known values. */
+ enum class Known {
+ IN_PROGRESS,
+ COMPLETED,
+ INCOMPLETE,
+ CALLING,
+ FAILED,
+ }
+
+ /**
+ * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Status] can contain an unknown value in a couple of cases:
+ * - It was deserialized from data that doesn't match any known member. For example, if
+ * the SDK is on an older version than the API, then the API may respond with new
+ * members that the SDK is unaware of.
+ * - It was constructed with an arbitrary value using the [of] method.
+ */
+ enum class Value {
+ IN_PROGRESS,
+ COMPLETED,
+ INCOMPLETE,
+ CALLING,
+ FAILED,
+ /**
+ * An enum member indicating that [Status] was instantiated with an unknown value.
+ */
+ _UNKNOWN,
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value, or
+ * [Value._UNKNOWN] if the class was instantiated with an unknown value.
+ *
+ * Use the [known] method instead if you're certain the value is always known or if you
+ * want to throw for the unknown case.
+ */
+ fun value(): Value =
+ when (this) {
+ IN_PROGRESS -> Value.IN_PROGRESS
+ COMPLETED -> Value.COMPLETED
+ INCOMPLETE -> Value.INCOMPLETE
+ CALLING -> Value.CALLING
+ FAILED -> Value.FAILED
+ else -> Value._UNKNOWN
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value.
+ *
+ * Use the [value] method instead if you're uncertain the value is always known and
+ * don't want to throw for the unknown case.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ IN_PROGRESS -> Known.IN_PROGRESS
+ COMPLETED -> Known.COMPLETED
+ INCOMPLETE -> Known.INCOMPLETE
+ CALLING -> Known.CALLING
+ FAILED -> Known.FAILED
+ else -> throw OpenAIInvalidDataException("Unknown Status: $value")
+ }
+
+ /**
+ * Returns this class instance's primitive wire representation.
+ *
+ * This differs from the [toString] method because that method is primarily for
+ * debugging and generally doesn't throw.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ OpenAIInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Status = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: OpenAIInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Status && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
override fun equals(other: Any?): Boolean {
if (this === other) {
@@ -4213,8 +4468,10 @@ private constructor(
name == other.name &&
serverLabel == other.serverLabel &&
type == other.type &&
+ approvalRequestId == other.approvalRequestId &&
error == other.error &&
output == other.output &&
+ status == other.status &&
additionalProperties == other.additionalProperties
}
@@ -4225,8 +4482,10 @@ private constructor(
name,
serverLabel,
type,
+ approvalRequestId,
error,
output,
+ status,
additionalProperties,
)
}
@@ -4234,6 +4493,6 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "McpCall{id=$id, arguments=$arguments, name=$name, serverLabel=$serverLabel, type=$type, error=$error, output=$output, additionalProperties=$additionalProperties}"
+ "McpCall{id=$id, arguments=$arguments, name=$name, serverLabel=$serverLabel, type=$type, approvalRequestId=$approvalRequestId, error=$error, output=$output, status=$status, additionalProperties=$additionalProperties}"
}
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt
index c90f01a0..dd4f51e3 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt
@@ -2076,8 +2076,10 @@ private constructor(
private val name: JsonField,
private val serverLabel: JsonField,
private val type: JsonValue,
+ private val approvalRequestId: JsonField,
private val error: JsonField,
private val output: JsonField,
+ private val status: JsonField,
private val additionalProperties: MutableMap,
) {
@@ -2092,9 +2094,24 @@ private constructor(
@ExcludeMissing
serverLabel: JsonField = JsonMissing.of(),
@JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
+ @JsonProperty("approval_request_id")
+ @ExcludeMissing
+ approvalRequestId: JsonField = JsonMissing.of(),
@JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(),
@JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(),
- ) : this(id, arguments, name, serverLabel, type, error, output, mutableMapOf())
+ @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(),
+ ) : this(
+ id,
+ arguments,
+ name,
+ serverLabel,
+ type,
+ approvalRequestId,
+ error,
+ output,
+ status,
+ mutableMapOf(),
+ )
/**
* The unique ID of the tool call.
@@ -2141,6 +2158,17 @@ private constructor(
*/
@JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
+ /**
+ * Unique identifier for the MCP tool call approval request. Include this value in a
+ * subsequent `mcp_approval_response` input to approve or reject the corresponding tool
+ * call.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun approvalRequestId(): Optional =
+ approvalRequestId.getOptional("approval_request_id")
+
/**
* The error from the tool call, if any.
*
@@ -2157,6 +2185,15 @@ private constructor(
*/
fun output(): Optional = output.getOptional("output")
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`,
+ * or `failed`.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun status(): Optional = status.getOptional("status")
+
/**
* Returns the raw JSON value of [id].
*
@@ -2187,6 +2224,16 @@ private constructor(
@ExcludeMissing
fun _serverLabel(): JsonField = serverLabel
+ /**
+ * Returns the raw JSON value of [approvalRequestId].
+ *
+ * Unlike [approvalRequestId], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("approval_request_id")
+ @ExcludeMissing
+ fun _approvalRequestId(): JsonField = approvalRequestId
+
/**
* Returns the raw JSON value of [error].
*
@@ -2201,6 +2248,13 @@ private constructor(
*/
@JsonProperty("output") @ExcludeMissing fun _output(): JsonField = output
+ /**
+ * Returns the raw JSON value of [status].
+ *
+ * Unlike [status], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status
+
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
@@ -2237,8 +2291,10 @@ private constructor(
private var name: JsonField? = null
private var serverLabel: JsonField? = null
private var type: JsonValue = JsonValue.from("mcp_call")
+ private var approvalRequestId: JsonField = JsonMissing.of()
private var error: JsonField = JsonMissing.of()
private var output: JsonField = JsonMissing.of()
+ private var status: JsonField = JsonMissing.of()
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -2248,8 +2304,10 @@ private constructor(
name = mcpCall.name
serverLabel = mcpCall.serverLabel
type = mcpCall.type
+ approvalRequestId = mcpCall.approvalRequestId
error = mcpCall.error
output = mcpCall.output
+ status = mcpCall.status
additionalProperties = mcpCall.additionalProperties.toMutableMap()
}
@@ -2317,6 +2375,31 @@ private constructor(
*/
fun type(type: JsonValue) = apply { this.type = type }
+ /**
+ * Unique identifier for the MCP tool call approval request. Include this value in a
+ * subsequent `mcp_approval_response` input to approve or reject the corresponding tool
+ * call.
+ */
+ fun approvalRequestId(approvalRequestId: String?) =
+ approvalRequestId(JsonField.ofNullable(approvalRequestId))
+
+ /**
+ * Alias for calling [Builder.approvalRequestId] with `approvalRequestId.orElse(null)`.
+ */
+ fun approvalRequestId(approvalRequestId: Optional) =
+ approvalRequestId(approvalRequestId.getOrNull())
+
+ /**
+ * Sets [Builder.approvalRequestId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.approvalRequestId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun approvalRequestId(approvalRequestId: JsonField) = apply {
+ this.approvalRequestId = approvalRequestId
+ }
+
/** The error from the tool call, if any. */
fun error(error: String?) = error(JsonField.ofNullable(error))
@@ -2347,6 +2430,21 @@ private constructor(
*/
fun output(output: JsonField) = apply { this.output = output }
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
+ * `calling`, or `failed`.
+ */
+ fun status(status: Status) = status(JsonField.of(status))
+
+ /**
+ * Sets [Builder.status] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.status] with a well-typed [Status] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun status(status: JsonField) = apply { this.status = status }
+
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
@@ -2388,8 +2486,10 @@ private constructor(
checkRequired("name", name),
checkRequired("serverLabel", serverLabel),
type,
+ approvalRequestId,
error,
output,
+ status,
additionalProperties.toMutableMap(),
)
}
@@ -2410,8 +2510,10 @@ private constructor(
throw OpenAIInvalidDataException("'type' is invalid, received $it")
}
}
+ approvalRequestId()
error()
output()
+ status().ifPresent { it.validate() }
validated = true
}
@@ -2436,8 +2538,161 @@ private constructor(
(if (name.asKnown().isPresent) 1 else 0) +
(if (serverLabel.asKnown().isPresent) 1 else 0) +
type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } +
+ (if (approvalRequestId.asKnown().isPresent) 1 else 0) +
(if (error.asKnown().isPresent) 1 else 0) +
- (if (output.asKnown().isPresent) 1 else 0)
+ (if (output.asKnown().isPresent) 1 else 0) +
+ (status.asKnown().getOrNull()?.validity() ?: 0)
+
+ /**
+ * The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`,
+ * or `failed`.
+ */
+ class Status @JsonCreator private constructor(private val value: JsonField) : Enum {
+
+ /**
+ * Returns this class instance's raw value.
+ *
+ * This is usually only useful if this instance was deserialized from data that doesn't
+ * match any known member, and you want to know that value. For example, if the SDK is
+ * on an older version than the API, then the API may respond with new members that the
+ * SDK is unaware of.
+ */
+ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
+
+ companion object {
+
+ @JvmField val IN_PROGRESS = of("in_progress")
+
+ @JvmField val COMPLETED = of("completed")
+
+ @JvmField val INCOMPLETE = of("incomplete")
+
+ @JvmField val CALLING = of("calling")
+
+ @JvmField val FAILED = of("failed")
+
+ @JvmStatic fun of(value: String) = Status(JsonField.of(value))
+ }
+
+ /** An enum containing [Status]'s known values. */
+ enum class Known {
+ IN_PROGRESS,
+ COMPLETED,
+ INCOMPLETE,
+ CALLING,
+ FAILED,
+ }
+
+ /**
+ * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Status] can contain an unknown value in a couple of cases:
+ * - It was deserialized from data that doesn't match any known member. For example, if
+ * the SDK is on an older version than the API, then the API may respond with new
+ * members that the SDK is unaware of.
+ * - It was constructed with an arbitrary value using the [of] method.
+ */
+ enum class Value {
+ IN_PROGRESS,
+ COMPLETED,
+ INCOMPLETE,
+ CALLING,
+ FAILED,
+ /**
+ * An enum member indicating that [Status] was instantiated with an unknown value.
+ */
+ _UNKNOWN,
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value, or
+ * [Value._UNKNOWN] if the class was instantiated with an unknown value.
+ *
+ * Use the [known] method instead if you're certain the value is always known or if you
+ * want to throw for the unknown case.
+ */
+ fun value(): Value =
+ when (this) {
+ IN_PROGRESS -> Value.IN_PROGRESS
+ COMPLETED -> Value.COMPLETED
+ INCOMPLETE -> Value.INCOMPLETE
+ CALLING -> Value.CALLING
+ FAILED -> Value.FAILED
+ else -> Value._UNKNOWN
+ }
+
+ /**
+ * Returns an enum member corresponding to this class instance's value.
+ *
+ * Use the [value] method instead if you're uncertain the value is always known and
+ * don't want to throw for the unknown case.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ IN_PROGRESS -> Known.IN_PROGRESS
+ COMPLETED -> Known.COMPLETED
+ INCOMPLETE -> Known.INCOMPLETE
+ CALLING -> Known.CALLING
+ FAILED -> Known.FAILED
+ else -> throw OpenAIInvalidDataException("Unknown Status: $value")
+ }
+
+ /**
+ * Returns this class instance's primitive wire representation.
+ *
+ * This differs from the [toString] method because that method is primarily for
+ * debugging and generally doesn't throw.
+ *
+ * @throws OpenAIInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ OpenAIInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Status = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: OpenAIInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Status && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
override fun equals(other: Any?): Boolean {
if (this === other) {
@@ -2450,8 +2705,10 @@ private constructor(
name == other.name &&
serverLabel == other.serverLabel &&
type == other.type &&
+ approvalRequestId == other.approvalRequestId &&
error == other.error &&
output == other.output &&
+ status == other.status &&
additionalProperties == other.additionalProperties
}
@@ -2462,8 +2719,10 @@ private constructor(
name,
serverLabel,
type,
+ approvalRequestId,
error,
output,
+ status,
additionalProperties,
)
}
@@ -2471,7 +2730,7 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "McpCall{id=$id, arguments=$arguments, name=$name, serverLabel=$serverLabel, type=$type, error=$error, output=$output, additionalProperties=$additionalProperties}"
+ "McpCall{id=$id, arguments=$arguments, name=$name, serverLabel=$serverLabel, type=$type, approvalRequestId=$approvalRequestId, error=$error, output=$output, status=$status, additionalProperties=$additionalProperties}"
}
/** A list of tools available on an MCP server. */
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt
index 6d827f08..0e32c416 100644
--- a/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt
@@ -977,8 +977,10 @@ internal class ConversationItemTest {
.arguments("arguments")
.name("name")
.serverLabel("server_label")
+ .approvalRequestId("approval_request_id")
.error("error")
.output("output")
+ .status(ConversationItem.McpCall.Status.IN_PROGRESS)
.build()
val conversationItem = ConversationItem.ofMcpCall(mcpCall)
@@ -1013,8 +1015,10 @@ internal class ConversationItemTest {
.arguments("arguments")
.name("name")
.serverLabel("server_label")
+ .approvalRequestId("approval_request_id")
.error("error")
.output("output")
+ .status(ConversationItem.McpCall.Status.IN_PROGRESS)
.build()
)
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt
index d98f1a56..557b79e7 100644
--- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt
@@ -1169,8 +1169,10 @@ internal class ResponseInputItemTest {
.arguments("arguments")
.name("name")
.serverLabel("server_label")
+ .approvalRequestId("approval_request_id")
.error("error")
.output("output")
+ .status(ResponseInputItem.McpCall.Status.IN_PROGRESS)
.build()
val responseInputItem = ResponseInputItem.ofMcpCall(mcpCall)
@@ -1208,8 +1210,10 @@ internal class ResponseInputItemTest {
.arguments("arguments")
.name("name")
.serverLabel("server_label")
+ .approvalRequestId("approval_request_id")
.error("error")
.output("output")
+ .status(ResponseInputItem.McpCall.Status.IN_PROGRESS)
.build()
)
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt
index e76ada84..aa46ea72 100644
--- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt
@@ -982,8 +982,10 @@ internal class ResponseItemTest {
.arguments("arguments")
.name("name")
.serverLabel("server_label")
+ .approvalRequestId("approval_request_id")
.error("error")
.output("output")
+ .status(ResponseItem.McpCall.Status.IN_PROGRESS)
.build()
val responseItem = ResponseItem.ofMcpCall(mcpCall)
@@ -1016,8 +1018,10 @@ internal class ResponseItemTest {
.arguments("arguments")
.name("name")
.serverLabel("server_label")
+ .approvalRequestId("approval_request_id")
.error("error")
.output("output")
+ .status(ResponseItem.McpCall.Status.IN_PROGRESS)
.build()
)
diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt
index 48522348..d7615365 100644
--- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt
+++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt
@@ -607,8 +607,10 @@ internal class ResponseOutputItemTest {
.arguments("arguments")
.name("name")
.serverLabel("server_label")
+ .approvalRequestId("approval_request_id")
.error("error")
.output("output")
+ .status(ResponseOutputItem.McpCall.Status.IN_PROGRESS)
.build()
val responseOutputItem = ResponseOutputItem.ofMcpCall(mcpCall)
@@ -638,8 +640,10 @@ internal class ResponseOutputItemTest {
.arguments("arguments")
.name("name")
.serverLabel("server_label")
+ .approvalRequestId("approval_request_id")
.error("error")
.output("output")
+ .status(ResponseOutputItem.McpCall.Status.IN_PROGRESS)
.build()
)