diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 733678539..3ab3b9e3d 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "2.46.0"
+ ".": "2.47.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 4888e3462..c45ebbf3c 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 116
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic/anthropic-04d07a5a32685ff9769f89d63e4ceaa49738b4d8dac73041bc9a691759350108.yml
-openapi_spec_hash: d793931588b3a62fad0cfbae27ad6654
-config_hash: 7315b549547ccd1891c7fe53f6a1796a
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic/anthropic-dffbd6e37f0be6d218800cdb283e5ad958c715021986d788e10c89c0a80a9f44.yml
+openapi_spec_hash: 753042938edfcbf43eb60c63c3369a30
+config_hash: 2fc184efddefac872a2f58876711b4f5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 584b42079..d5cf57085 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## 2.47.0 (2026-06-30)
+
+Full Changelog: [v2.46.0...v2.47.0](https://github.com/anthropics/anthropic-sdk-java/compare/v2.46.0...v2.47.0)
+
+### Features
+
+* **api:** add support for Managed Agents event delta streaming, agent overrides, reverse pagination, vault credential injection scoping, and agent and deployment webhook events ([5eed04b](https://github.com/anthropics/anthropic-sdk-java/commit/5eed04b793a44b9d3dabbafe079d88ba0ac6651f))
+
## 2.46.0 (2026-06-30)
Full Changelog: [v2.45.0...v2.46.0](https://github.com/anthropics/anthropic-sdk-java/compare/v2.45.0...v2.46.0)
diff --git a/README.md b/README.md
index 0553f95bb..468ca10a8 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ Full documentation is available at **[platform.claude.com/docs/en/api/sdks/java]
### Gradle
```kotlin
-implementation("com.anthropic:anthropic-java:2.46.0")
+implementation("com.anthropic:anthropic-java:2.47.0")
```
### Maven
@@ -24,7 +24,7 @@ implementation("com.anthropic:anthropic-java:2.46.0")
com.anthropic
anthropic-java
- 2.46.0
+ 2.47.0
```
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/SseHandler.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/SseHandler.kt
index 35c154fda..7f79aed77 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/SseHandler.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/handlers/SseHandler.kt
@@ -66,6 +66,8 @@ internal fun sseHandler(jsonMapper: JsonMapper): Handler yield(message)
"ping" -> continue
"error" -> {
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/BetaSelfHostedWork.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/BetaSelfHostedWork.kt
index d8eb3071d..f5e067341 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/BetaSelfHostedWork.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/BetaSelfHostedWork.kt
@@ -35,6 +35,7 @@ private constructor(
private val environmentId: JsonField,
private val latestHeartbeatAt: JsonField,
private val metadata: JsonField,
+ private val secret: JsonField,
private val startedAt: JsonField,
private val state: JsonField,
private val stopRequestedAt: JsonField,
@@ -60,6 +61,7 @@ private constructor(
@ExcludeMissing
latestHeartbeatAt: JsonField = JsonMissing.of(),
@JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(),
+ @JsonProperty("secret") @ExcludeMissing secret: JsonField = JsonMissing.of(),
@JsonProperty("started_at") @ExcludeMissing startedAt: JsonField = JsonMissing.of(),
@JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(),
@JsonProperty("stop_requested_at")
@@ -75,6 +77,7 @@ private constructor(
environmentId,
latestHeartbeatAt,
metadata,
+ secret,
startedAt,
state,
stopRequestedAt,
@@ -139,6 +142,15 @@ private constructor(
*/
fun metadata(): Metadata = metadata.getRequired("metadata")
+ /**
+ * Credential payload used by the environment worker to execute this work item. May be populated
+ * when polling for work; null on all other retrieval paths.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun secret(): Optional = secret.getOptional("secret")
+
/**
* RFC 3339 timestamp when work execution started
*
@@ -240,6 +252,13 @@ private constructor(
*/
@JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata
+ /**
+ * Returns the raw JSON value of [secret].
+ *
+ * Unlike [secret], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret
+
/**
* Returns the raw JSON value of [startedAt].
*
@@ -296,6 +315,7 @@ private constructor(
* .environmentId()
* .latestHeartbeatAt()
* .metadata()
+ * .secret()
* .startedAt()
* .state()
* .stopRequestedAt()
@@ -315,6 +335,7 @@ private constructor(
private var environmentId: JsonField? = null
private var latestHeartbeatAt: JsonField? = null
private var metadata: JsonField? = null
+ private var secret: JsonField? = null
private var startedAt: JsonField? = null
private var state: JsonField? = null
private var stopRequestedAt: JsonField? = null
@@ -331,6 +352,7 @@ private constructor(
environmentId = betaSelfHostedWork.environmentId
latestHeartbeatAt = betaSelfHostedWork.latestHeartbeatAt
metadata = betaSelfHostedWork.metadata
+ secret = betaSelfHostedWork.secret
startedAt = betaSelfHostedWork.startedAt
state = betaSelfHostedWork.state
stopRequestedAt = betaSelfHostedWork.stopRequestedAt
@@ -441,6 +463,23 @@ private constructor(
*/
fun metadata(metadata: JsonField) = apply { this.metadata = metadata }
+ /**
+ * Credential payload used by the environment worker to execute this work item. May be
+ * populated when polling for work; null on all other retrieval paths.
+ */
+ fun secret(secret: String?) = secret(JsonField.ofNullable(secret))
+
+ /** Alias for calling [Builder.secret] with `secret.orElse(null)`. */
+ fun secret(secret: Optional) = secret(secret.getOrNull())
+
+ /**
+ * Sets [Builder.secret] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.secret] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun secret(secret: JsonField) = apply { this.secret = secret }
+
/** RFC 3339 timestamp when work execution started */
fun startedAt(startedAt: String?) = startedAt(JsonField.ofNullable(startedAt))
@@ -548,6 +587,7 @@ private constructor(
* .environmentId()
* .latestHeartbeatAt()
* .metadata()
+ * .secret()
* .startedAt()
* .state()
* .stopRequestedAt()
@@ -565,6 +605,7 @@ private constructor(
checkRequired("environmentId", environmentId),
checkRequired("latestHeartbeatAt", latestHeartbeatAt),
checkRequired("metadata", metadata),
+ checkRequired("secret", secret),
checkRequired("startedAt", startedAt),
checkRequired("state", state),
checkRequired("stopRequestedAt", stopRequestedAt),
@@ -596,6 +637,7 @@ private constructor(
environmentId()
latestHeartbeatAt()
metadata().validate()
+ secret()
startedAt()
state().validate()
stopRequestedAt()
@@ -630,6 +672,7 @@ private constructor(
(if (environmentId.asKnown().isPresent) 1 else 0) +
(if (latestHeartbeatAt.asKnown().isPresent) 1 else 0) +
(metadata.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (secret.asKnown().isPresent) 1 else 0) +
(if (startedAt.asKnown().isPresent) 1 else 0) +
(state.asKnown().getOrNull()?.validity() ?: 0) +
(if (stopRequestedAt.asKnown().isPresent) 1 else 0) +
@@ -913,6 +956,7 @@ private constructor(
environmentId == other.environmentId &&
latestHeartbeatAt == other.latestHeartbeatAt &&
metadata == other.metadata &&
+ secret == other.secret &&
startedAt == other.startedAt &&
state == other.state &&
stopRequestedAt == other.stopRequestedAt &&
@@ -930,6 +974,7 @@ private constructor(
environmentId,
latestHeartbeatAt,
metadata,
+ secret,
startedAt,
state,
stopRequestedAt,
@@ -942,5 +987,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
- "BetaSelfHostedWork{id=$id, acknowledgedAt=$acknowledgedAt, createdAt=$createdAt, data=$data, environmentId=$environmentId, latestHeartbeatAt=$latestHeartbeatAt, metadata=$metadata, startedAt=$startedAt, state=$state, stopRequestedAt=$stopRequestedAt, stoppedAt=$stoppedAt, type=$type, additionalProperties=$additionalProperties}"
+ "BetaSelfHostedWork{id=$id, acknowledgedAt=$acknowledgedAt, createdAt=$createdAt, data=$data, environmentId=$environmentId, latestHeartbeatAt=$latestHeartbeatAt, metadata=$metadata, secret=$secret, startedAt=$startedAt, state=$state, stopRequestedAt=$stopRequestedAt, stoppedAt=$stoppedAt, type=$type, additionalProperties=$additionalProperties}"
}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAgentMessagePreview.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAgentMessagePreview.kt
new file mode 100644
index 000000000..fa0b77929
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAgentMessagePreview.kt
@@ -0,0 +1,355 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkRequired
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+class BetaManagedAgentsAgentMessagePreview
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val id: JsonField,
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ ) : this(id, type, mutableMapOf())
+
+ /**
+ * The id the buffered agent.message will carry if it is emitted. Matches the event_id on this
+ * preview's event_delta events.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun id(): String = id.getRequired("id")
+
+ /**
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun type(): Type = type.getRequired("type")
+
+ /**
+ * Returns the raw JSON value of [id].
+ *
+ * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
+
+ /**
+ * Returns the raw JSON value of [type].
+ *
+ * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of
+ * [BetaManagedAgentsAgentMessagePreview].
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsAgentMessagePreview]. */
+ class Builder internal constructor() {
+
+ private var id: JsonField? = null
+ private var type: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(
+ betaManagedAgentsAgentMessagePreview: BetaManagedAgentsAgentMessagePreview
+ ) = apply {
+ id = betaManagedAgentsAgentMessagePreview.id
+ type = betaManagedAgentsAgentMessagePreview.type
+ additionalProperties =
+ betaManagedAgentsAgentMessagePreview.additionalProperties.toMutableMap()
+ }
+
+ /**
+ * The id the buffered agent.message will carry if it is emitted. Matches the event_id on
+ * this preview's event_delta events.
+ */
+ fun id(id: String) = id(JsonField.of(id))
+
+ /**
+ * Sets [Builder.id] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.id] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun id(id: JsonField) = apply { this.id = id }
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun type(type: JsonField) = apply { this.type = type }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [BetaManagedAgentsAgentMessagePreview].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsAgentMessagePreview =
+ BetaManagedAgentsAgentMessagePreview(
+ checkRequired("id", id),
+ checkRequired("type", type),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsAgentMessagePreview = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ type().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 (id.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0)
+
+ class Type @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 AGENT_MESSAGE = of("agent.message")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ AGENT_MESSAGE
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ AGENT_MESSAGE,
+ /** An enum member indicating that [Type] 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) {
+ AGENT_MESSAGE -> Value.AGENT_MESSAGE
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ AGENT_MESSAGE -> Known.AGENT_MESSAGE
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsAgentMessagePreview &&
+ id == other.id &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsAgentMessagePreview{id=$id, type=$type, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAgentThinkingPreview.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAgentThinkingPreview.kt
new file mode 100644
index 000000000..fe687221e
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAgentThinkingPreview.kt
@@ -0,0 +1,355 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkRequired
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+class BetaManagedAgentsAgentThinkingPreview
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val id: JsonField,
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ ) : this(id, type, mutableMapOf())
+
+ /**
+ * The id the buffered agent.thinking will carry if it is emitted. Start-only — no event_delta
+ * events follow.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun id(): String = id.getRequired("id")
+
+ /**
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun type(): Type = type.getRequired("type")
+
+ /**
+ * Returns the raw JSON value of [id].
+ *
+ * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
+
+ /**
+ * Returns the raw JSON value of [type].
+ *
+ * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of
+ * [BetaManagedAgentsAgentThinkingPreview].
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsAgentThinkingPreview]. */
+ class Builder internal constructor() {
+
+ private var id: JsonField? = null
+ private var type: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(
+ betaManagedAgentsAgentThinkingPreview: BetaManagedAgentsAgentThinkingPreview
+ ) = apply {
+ id = betaManagedAgentsAgentThinkingPreview.id
+ type = betaManagedAgentsAgentThinkingPreview.type
+ additionalProperties =
+ betaManagedAgentsAgentThinkingPreview.additionalProperties.toMutableMap()
+ }
+
+ /**
+ * The id the buffered agent.thinking will carry if it is emitted. Start-only — no
+ * event_delta events follow.
+ */
+ fun id(id: String) = id(JsonField.of(id))
+
+ /**
+ * Sets [Builder.id] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.id] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun id(id: JsonField) = apply { this.id = id }
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun type(type: JsonField) = apply { this.type = type }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [BetaManagedAgentsAgentThinkingPreview].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsAgentThinkingPreview =
+ BetaManagedAgentsAgentThinkingPreview(
+ checkRequired("id", id),
+ checkRequired("type", type),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsAgentThinkingPreview = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ type().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 (id.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0)
+
+ class Type @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 AGENT_THINKING = of("agent.thinking")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ AGENT_THINKING
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ AGENT_THINKING,
+ /** An enum member indicating that [Type] 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) {
+ AGENT_THINKING -> Value.AGENT_THINKING
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ AGENT_THINKING -> Known.AGENT_THINKING
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsAgentThinkingPreview &&
+ id == other.id &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsAgentThinkingPreview{id=$id, type=$type, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAgentWithOverridesParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAgentWithOverridesParams.kt
new file mode 100644
index 000000000..57d03bb8e
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAgentWithOverridesParams.kt
@@ -0,0 +1,1332 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.BaseDeserializer
+import com.anthropic.core.BaseSerializer
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.allMaxBy
+import com.anthropic.core.checkKnown
+import com.anthropic.core.checkRequired
+import com.anthropic.core.getOrThrow
+import com.anthropic.core.toImmutable
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.anthropic.models.beta.agents.BetaManagedAgentsAgentToolset20260401Params
+import com.anthropic.models.beta.agents.BetaManagedAgentsAnthropicSkillParams
+import com.anthropic.models.beta.agents.BetaManagedAgentsCustomSkillParams
+import com.anthropic.models.beta.agents.BetaManagedAgentsCustomToolParams
+import com.anthropic.models.beta.agents.BetaManagedAgentsMcpToolsetParams
+import com.anthropic.models.beta.agents.BetaManagedAgentsModel
+import com.anthropic.models.beta.agents.BetaManagedAgentsModelConfigParams
+import com.anthropic.models.beta.agents.BetaManagedAgentsSkillParams
+import com.anthropic.models.beta.agents.BetaManagedAgentsUrlMcpServerParams
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import com.fasterxml.jackson.core.JsonGenerator
+import com.fasterxml.jackson.core.ObjectCodec
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.SerializerProvider
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize
+import com.fasterxml.jackson.databind.annotation.JsonSerialize
+import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
+import java.util.Collections
+import java.util.Objects
+import java.util.Optional
+import kotlin.jvm.optionals.getOrNull
+
+/**
+ * Reference to an `agent` plus optional configuration overrides. Each provided field replaces the
+ * agent's value for the caller's use; the agent resource is unchanged.
+ */
+class BetaManagedAgentsAgentWithOverridesParams
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val id: JsonField,
+ private val type: JsonField,
+ private val mcpServers: JsonField>,
+ private val model: JsonField,
+ private val skills: JsonField>,
+ private val system: JsonField,
+ private val tools: JsonField>,
+ private val version: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ @JsonProperty("mcp_servers")
+ @ExcludeMissing
+ mcpServers: JsonField> = JsonMissing.of(),
+ @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(),
+ @JsonProperty("skills")
+ @ExcludeMissing
+ skills: JsonField> = JsonMissing.of(),
+ @JsonProperty("system") @ExcludeMissing system: JsonField = JsonMissing.of(),
+ @JsonProperty("tools") @ExcludeMissing tools: JsonField> = JsonMissing.of(),
+ @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(),
+ ) : this(id, type, mcpServers, model, skills, system, tools, version, mutableMapOf())
+
+ /**
+ * The `agent` ID.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun id(): String = id.getRequired("id")
+
+ /**
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun type(): Type = type.getRequired("type")
+
+ /**
+ * Replacement MCP server list. Full replacement: the provided array becomes the MCP servers.
+ * Send an empty array to clear; omit to preserve the agent's servers.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun mcpServers(): Optional> =
+ mcpServers.getOptional("mcp_servers")
+
+ /**
+ * Replacement model. Accepts the model string, e.g. `claude-opus-4-6`, or a `model_config`
+ * object. Omit to use the agent's model.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun model(): Optional = model.getOptional("model")
+
+ /**
+ * Replacement skill list. Full replacement: the provided array becomes the skills. Send an
+ * empty array to clear; omit to preserve the agent's skills.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun skills(): Optional> = skills.getOptional("skills")
+
+ /**
+ * Replacement system prompt. Up to 100,000 characters. Set to null to clear the agent's system
+ * prompt; omit to preserve it.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun system(): Optional = system.getOptional("system")
+
+ /**
+ * Replacement tool list. Full replacement: the provided array becomes the tool configuration.
+ * Send an empty array to clear; omit to preserve the agent's tools.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun tools(): Optional> = tools.getOptional("tools")
+
+ /**
+ * The specific `agent` version to use. Omit to use the latest version.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun version(): Optional = version.getOptional("version")
+
+ /**
+ * Returns the raw JSON value of [id].
+ *
+ * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
+
+ /**
+ * Returns the raw JSON value of [type].
+ *
+ * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
+
+ /**
+ * Returns the raw JSON value of [mcpServers].
+ *
+ * Unlike [mcpServers], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("mcp_servers")
+ @ExcludeMissing
+ fun _mcpServers(): JsonField> = mcpServers
+
+ /**
+ * Returns the raw JSON value of [model].
+ *
+ * Unlike [model], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model
+
+ /**
+ * Returns the raw JSON value of [skills].
+ *
+ * Unlike [skills], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("skills")
+ @ExcludeMissing
+ fun _skills(): JsonField> = skills
+
+ /**
+ * Returns the raw JSON value of [system].
+ *
+ * Unlike [system], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("system") @ExcludeMissing fun _system(): JsonField = system
+
+ /**
+ * Returns the raw JSON value of [tools].
+ *
+ * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("tools") @ExcludeMissing fun _tools(): JsonField> = tools
+
+ /**
+ * Returns the raw JSON value of [version].
+ *
+ * Unlike [version], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of
+ * [BetaManagedAgentsAgentWithOverridesParams].
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsAgentWithOverridesParams]. */
+ class Builder internal constructor() {
+
+ private var id: JsonField? = null
+ private var type: JsonField? = null
+ private var mcpServers: JsonField>? = null
+ private var model: JsonField = JsonMissing.of()
+ private var skills: JsonField>? = null
+ private var system: JsonField = JsonMissing.of()
+ private var tools: JsonField>? = null
+ private var version: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(
+ betaManagedAgentsAgentWithOverridesParams: BetaManagedAgentsAgentWithOverridesParams
+ ) = apply {
+ id = betaManagedAgentsAgentWithOverridesParams.id
+ type = betaManagedAgentsAgentWithOverridesParams.type
+ mcpServers =
+ betaManagedAgentsAgentWithOverridesParams.mcpServers
+ .map { it.toMutableList() }
+ .takeUnless { it.isMissing() }
+ model = betaManagedAgentsAgentWithOverridesParams.model
+ skills =
+ betaManagedAgentsAgentWithOverridesParams.skills
+ .map { it.toMutableList() }
+ .takeUnless { it.isMissing() }
+ system = betaManagedAgentsAgentWithOverridesParams.system
+ tools =
+ betaManagedAgentsAgentWithOverridesParams.tools
+ .map { it.toMutableList() }
+ .takeUnless { it.isMissing() }
+ version = betaManagedAgentsAgentWithOverridesParams.version
+ additionalProperties =
+ betaManagedAgentsAgentWithOverridesParams.additionalProperties.toMutableMap()
+ }
+
+ /** The `agent` ID. */
+ fun id(id: String) = id(JsonField.of(id))
+
+ /**
+ * Sets [Builder.id] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.id] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun id(id: JsonField) = apply { this.id = id }
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun type(type: JsonField) = apply { this.type = type }
+
+ /**
+ * Replacement MCP server list. Full replacement: the provided array becomes the MCP
+ * servers. Send an empty array to clear; omit to preserve the agent's servers.
+ */
+ fun mcpServers(mcpServers: List) =
+ mcpServers(JsonField.of(mcpServers))
+
+ /**
+ * Sets [Builder.mcpServers] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.mcpServers] with a well-typed
+ * `List` value instead. This method is primarily for
+ * setting the field to an undocumented or not yet supported value.
+ */
+ fun mcpServers(mcpServers: JsonField>) = apply {
+ this.mcpServers = mcpServers.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [BetaManagedAgentsUrlMcpServerParams] to [mcpServers].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addMcpServer(mcpServer: BetaManagedAgentsUrlMcpServerParams) = apply {
+ mcpServers =
+ (mcpServers ?: JsonField.of(mutableListOf())).also {
+ checkKnown("mcpServers", it).add(mcpServer)
+ }
+ }
+
+ /**
+ * Replacement model. Accepts the model string, e.g. `claude-opus-4-6`, or a `model_config`
+ * object. Omit to use the agent's model.
+ */
+ fun model(model: Model) = model(JsonField.of(model))
+
+ /**
+ * Sets [Builder.model] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.model] with a well-typed [Model] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun model(model: JsonField) = apply { this.model = model }
+
+ /** Alias for calling [model] with `Model.ofBetaManagedAgents(betaManagedAgents)`. */
+ fun model(betaManagedAgents: BetaManagedAgentsModel) =
+ model(Model.ofBetaManagedAgents(betaManagedAgents))
+
+ /**
+ * Alias for calling [model] with
+ * `Model.ofBetaManagedAgentsModelConfigParams(betaManagedAgentsModelConfigParams)`.
+ */
+ fun model(betaManagedAgentsModelConfigParams: BetaManagedAgentsModelConfigParams) =
+ model(Model.ofBetaManagedAgentsModelConfigParams(betaManagedAgentsModelConfigParams))
+
+ /**
+ * Replacement skill list. Full replacement: the provided array becomes the skills. Send an
+ * empty array to clear; omit to preserve the agent's skills.
+ */
+ fun skills(skills: List) = skills(JsonField.of(skills))
+
+ /**
+ * Sets [Builder.skills] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.skills] with a well-typed
+ * `List` value instead. This method is primarily for setting
+ * the field to an undocumented or not yet supported value.
+ */
+ fun skills(skills: JsonField>) = apply {
+ this.skills = skills.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [BetaManagedAgentsSkillParams] to [skills].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addSkill(skill: BetaManagedAgentsSkillParams) = apply {
+ skills =
+ (skills ?: JsonField.of(mutableListOf())).also {
+ checkKnown("skills", it).add(skill)
+ }
+ }
+
+ /**
+ * Alias for calling [addSkill] with `BetaManagedAgentsSkillParams.ofAnthropic(anthropic)`.
+ */
+ fun addSkill(anthropic: BetaManagedAgentsAnthropicSkillParams) =
+ addSkill(BetaManagedAgentsSkillParams.ofAnthropic(anthropic))
+
+ /**
+ * Alias for calling [addSkill] with the following:
+ * ```java
+ * BetaManagedAgentsAnthropicSkillParams.builder()
+ * .type(BetaManagedAgentsAnthropicSkillParams.Type.ANTHROPIC)
+ * .skillId(skillId)
+ * .build()
+ * ```
+ */
+ fun addAnthropicSkill(skillId: String) =
+ addSkill(
+ BetaManagedAgentsAnthropicSkillParams.builder()
+ .type(BetaManagedAgentsAnthropicSkillParams.Type.ANTHROPIC)
+ .skillId(skillId)
+ .build()
+ )
+
+ /** Alias for calling [addSkill] with `BetaManagedAgentsSkillParams.ofCustom(custom)`. */
+ fun addSkill(custom: BetaManagedAgentsCustomSkillParams) =
+ addSkill(BetaManagedAgentsSkillParams.ofCustom(custom))
+
+ /**
+ * Alias for calling [addSkill] with the following:
+ * ```java
+ * BetaManagedAgentsCustomSkillParams.builder()
+ * .type(BetaManagedAgentsCustomSkillParams.Type.CUSTOM)
+ * .skillId(skillId)
+ * .build()
+ * ```
+ */
+ fun addCustomSkill(skillId: String) =
+ addSkill(
+ BetaManagedAgentsCustomSkillParams.builder()
+ .type(BetaManagedAgentsCustomSkillParams.Type.CUSTOM)
+ .skillId(skillId)
+ .build()
+ )
+
+ /**
+ * Replacement system prompt. Up to 100,000 characters. Set to null to clear the agent's
+ * system prompt; omit to preserve it.
+ */
+ fun system(system: String?) = system(JsonField.ofNullable(system))
+
+ /** Alias for calling [Builder.system] with `system.orElse(null)`. */
+ fun system(system: Optional) = system(system.getOrNull())
+
+ /**
+ * Sets [Builder.system] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.system] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun system(system: JsonField) = apply { this.system = system }
+
+ /**
+ * Replacement tool list. Full replacement: the provided array becomes the tool
+ * configuration. Send an empty array to clear; omit to preserve the agent's tools.
+ */
+ fun tools(tools: List) = tools(JsonField.of(tools))
+
+ /**
+ * Sets [Builder.tools] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.tools] with a well-typed `List` value instead.
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun tools(tools: JsonField>) = apply {
+ this.tools = tools.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [Tool] to [tools].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addTool(tool: Tool) = apply {
+ tools =
+ (tools ?: JsonField.of(mutableListOf())).also { checkKnown("tools", it).add(tool) }
+ }
+
+ /** Alias for calling [addTool] with `Tool.ofAgentToolset20260401(agentToolset20260401)`. */
+ fun addTool(agentToolset20260401: BetaManagedAgentsAgentToolset20260401Params) =
+ addTool(Tool.ofAgentToolset20260401(agentToolset20260401))
+
+ /** Alias for calling [addTool] with `Tool.ofMcpToolset(mcpToolset)`. */
+ fun addTool(mcpToolset: BetaManagedAgentsMcpToolsetParams) =
+ addTool(Tool.ofMcpToolset(mcpToolset))
+
+ /**
+ * Alias for calling [addTool] with the following:
+ * ```java
+ * BetaManagedAgentsMcpToolsetParams.builder()
+ * .type(BetaManagedAgentsMcpToolsetParams.Type.MCP_TOOLSET)
+ * .mcpServerName(mcpServerName)
+ * .build()
+ * ```
+ */
+ fun addMcpToolsetTool(mcpServerName: String) =
+ addTool(
+ BetaManagedAgentsMcpToolsetParams.builder()
+ .type(BetaManagedAgentsMcpToolsetParams.Type.MCP_TOOLSET)
+ .mcpServerName(mcpServerName)
+ .build()
+ )
+
+ /** Alias for calling [addTool] with `Tool.ofCustom(custom)`. */
+ fun addTool(custom: BetaManagedAgentsCustomToolParams) = addTool(Tool.ofCustom(custom))
+
+ /** The specific `agent` version to use. Omit to use the latest version. */
+ fun version(version: Int) = version(JsonField.of(version))
+
+ /**
+ * Sets [Builder.version] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.version] with a well-typed [Int] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun version(version: JsonField) = apply { this.version = version }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [BetaManagedAgentsAgentWithOverridesParams].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsAgentWithOverridesParams =
+ BetaManagedAgentsAgentWithOverridesParams(
+ checkRequired("id", id),
+ checkRequired("type", type),
+ (mcpServers ?: JsonMissing.of()).map { it.toImmutable() },
+ model,
+ (skills ?: JsonMissing.of()).map { it.toImmutable() },
+ system,
+ (tools ?: JsonMissing.of()).map { it.toImmutable() },
+ version,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsAgentWithOverridesParams = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ type().validate()
+ mcpServers().ifPresent { it.forEach { it.validate() } }
+ model().ifPresent { it.validate() }
+ skills().ifPresent { it.forEach { it.validate() } }
+ system()
+ tools().ifPresent { it.forEach { it.validate() } }
+ version()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 (id.asKnown().isPresent) 1 else 0) +
+ (type.asKnown().getOrNull()?.validity() ?: 0) +
+ (mcpServers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
+ (model.asKnown().getOrNull()?.validity() ?: 0) +
+ (skills.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
+ (if (system.asKnown().isPresent) 1 else 0) +
+ (tools.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
+ (if (version.asKnown().isPresent) 1 else 0)
+
+ class Type @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 AGENT_WITH_OVERRIDES = of("agent_with_overrides")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ AGENT_WITH_OVERRIDES
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ AGENT_WITH_OVERRIDES,
+ /** An enum member indicating that [Type] 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) {
+ AGENT_WITH_OVERRIDES -> Value.AGENT_WITH_OVERRIDES
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ AGENT_WITH_OVERRIDES -> Known.AGENT_WITH_OVERRIDES
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ /**
+ * Replacement model. Accepts the model string, e.g. `claude-opus-4-6`, or a `model_config`
+ * object. Omit to use the agent's model.
+ */
+ @JsonDeserialize(using = Model.Deserializer::class)
+ @JsonSerialize(using = Model.Serializer::class)
+ class Model
+ private constructor(
+ private val betaManagedAgents: BetaManagedAgentsModel? = null,
+ private val betaManagedAgentsModelConfigParams: BetaManagedAgentsModelConfigParams? = null,
+ private val _json: JsonValue? = null,
+ ) {
+
+ /**
+ * The model that will power your agent.
+ *
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details
+ * and options.
+ */
+ fun betaManagedAgents(): Optional =
+ Optional.ofNullable(betaManagedAgents)
+
+ /** An object that defines additional configuration control over model use */
+ fun betaManagedAgentsModelConfigParams(): Optional =
+ Optional.ofNullable(betaManagedAgentsModelConfigParams)
+
+ fun isBetaManagedAgents(): Boolean = betaManagedAgents != null
+
+ fun isBetaManagedAgentsModelConfigParams(): Boolean =
+ betaManagedAgentsModelConfigParams != null
+
+ /**
+ * The model that will power your agent.
+ *
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details
+ * and options.
+ */
+ fun asBetaManagedAgents(): BetaManagedAgentsModel =
+ betaManagedAgents.getOrThrow("betaManagedAgents")
+
+ /** An object that defines additional configuration control over model use */
+ fun asBetaManagedAgentsModelConfigParams(): BetaManagedAgentsModelConfigParams =
+ betaManagedAgentsModelConfigParams.getOrThrow("betaManagedAgentsModelConfigParams")
+
+ fun _json(): Optional = Optional.ofNullable(_json)
+
+ /**
+ * Maps this instance's current variant to a value of type [T] using the given [visitor].
+ *
+ * Note that this method is _not_ forwards compatible with new variants from the API, unless
+ * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of
+ * the SDK gracefully, consider overriding [Visitor.unknown]:
+ * ```java
+ * import com.anthropic.core.JsonValue;
+ * import java.util.Optional;
+ *
+ * Optional result = model.accept(new Model.Visitor>() {
+ * @Override
+ * public Optional visitBetaManagedAgents(BetaManagedAgentsModel betaManagedAgents) {
+ * return Optional.of(betaManagedAgents.toString());
+ * }
+ *
+ * // ...
+ *
+ * @Override
+ * public Optional unknown(JsonValue json) {
+ * // Or inspect the `json`.
+ * return Optional.empty();
+ * }
+ * });
+ * ```
+ *
+ * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor]
+ * and the current variant is unknown.
+ */
+ fun accept(visitor: Visitor): T =
+ when {
+ betaManagedAgents != null -> visitor.visitBetaManagedAgents(betaManagedAgents)
+ betaManagedAgentsModelConfigParams != null ->
+ visitor.visitBetaManagedAgentsModelConfigParams(
+ betaManagedAgentsModelConfigParams
+ )
+ else -> visitor.unknown(_json)
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Model = apply {
+ if (validated) {
+ return@apply
+ }
+
+ accept(
+ object : Visitor {
+ override fun visitBetaManagedAgents(
+ betaManagedAgents: BetaManagedAgentsModel
+ ) {}
+
+ override fun visitBetaManagedAgentsModelConfigParams(
+ betaManagedAgentsModelConfigParams: BetaManagedAgentsModelConfigParams
+ ) {
+ betaManagedAgentsModelConfigParams.validate()
+ }
+ }
+ )
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 =
+ accept(
+ object : Visitor {
+ override fun visitBetaManagedAgents(betaManagedAgents: BetaManagedAgentsModel) =
+ 1
+
+ override fun visitBetaManagedAgentsModelConfigParams(
+ betaManagedAgentsModelConfigParams: BetaManagedAgentsModelConfigParams
+ ) = betaManagedAgentsModelConfigParams.validity()
+
+ override fun unknown(json: JsonValue?) = 0
+ }
+ )
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Model &&
+ betaManagedAgents == other.betaManagedAgents &&
+ betaManagedAgentsModelConfigParams == other.betaManagedAgentsModelConfigParams
+ }
+
+ override fun hashCode(): Int =
+ Objects.hash(betaManagedAgents, betaManagedAgentsModelConfigParams)
+
+ override fun toString(): String =
+ when {
+ betaManagedAgents != null -> "Model{betaManagedAgents=$betaManagedAgents}"
+ betaManagedAgentsModelConfigParams != null ->
+ "Model{betaManagedAgentsModelConfigParams=$betaManagedAgentsModelConfigParams}"
+ _json != null -> "Model{_unknown=$_json}"
+ else -> throw IllegalStateException("Invalid Model")
+ }
+
+ companion object {
+
+ /**
+ * The model that will power your agent.
+ *
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
+ * details and options.
+ */
+ @JvmStatic
+ fun ofBetaManagedAgents(betaManagedAgents: BetaManagedAgentsModel) =
+ Model(betaManagedAgents = betaManagedAgents)
+
+ /** An object that defines additional configuration control over model use */
+ @JvmStatic
+ fun ofBetaManagedAgentsModelConfigParams(
+ betaManagedAgentsModelConfigParams: BetaManagedAgentsModelConfigParams
+ ) = Model(betaManagedAgentsModelConfigParams = betaManagedAgentsModelConfigParams)
+ }
+
+ /** An interface that defines how to map each variant of [Model] to a value of type [T]. */
+ interface Visitor {
+
+ /**
+ * The model that will power your agent.
+ *
+ * See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
+ * details and options.
+ */
+ fun visitBetaManagedAgents(betaManagedAgents: BetaManagedAgentsModel): T
+
+ /** An object that defines additional configuration control over model use */
+ fun visitBetaManagedAgentsModelConfigParams(
+ betaManagedAgentsModelConfigParams: BetaManagedAgentsModelConfigParams
+ ): T
+
+ /**
+ * Maps an unknown variant of [Model] to a value of type [T].
+ *
+ * An instance of [Model] can contain an unknown variant if it was deserialized from
+ * data that doesn't match any known variant. For example, if the SDK is on an older
+ * version than the API, then the API may respond with new variants that the SDK is
+ * unaware of.
+ *
+ * @throws AnthropicInvalidDataException in the default implementation.
+ */
+ fun unknown(json: JsonValue?): T {
+ throw AnthropicInvalidDataException("Unknown Model: $json")
+ }
+ }
+
+ internal class Deserializer : BaseDeserializer(Model::class) {
+
+ override fun ObjectCodec.deserialize(node: JsonNode): Model {
+ val json = JsonValue.fromJsonNode(node)
+
+ val bestMatches =
+ sequenceOf(
+ tryDeserialize(node, jacksonTypeRef())?.let {
+ Model(betaManagedAgents = it, _json = json)
+ },
+ tryDeserialize(
+ node,
+ jacksonTypeRef(),
+ )
+ ?.let {
+ Model(betaManagedAgentsModelConfigParams = it, _json = json)
+ },
+ )
+ .filterNotNull()
+ .allMaxBy { it.validity() }
+ .toList()
+ return when (bestMatches.size) {
+ // This can happen if what we're deserializing is completely incompatible with
+ // all the possible variants (e.g. deserializing from boolean).
+ 0 -> Model(_json = json)
+ 1 -> bestMatches.single()
+ // If there's more than one match with the highest validity, then use the first
+ // completely valid match, or simply the first match if none are completely
+ // valid.
+ else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first()
+ }
+ }
+ }
+
+ internal class Serializer : BaseSerializer(Model::class) {
+
+ override fun serialize(
+ value: Model,
+ generator: JsonGenerator,
+ provider: SerializerProvider,
+ ) {
+ when {
+ value.betaManagedAgents != null ->
+ generator.writeObject(value.betaManagedAgents)
+ value.betaManagedAgentsModelConfigParams != null ->
+ generator.writeObject(value.betaManagedAgentsModelConfigParams)
+ value._json != null -> generator.writeObject(value._json)
+ else -> throw IllegalStateException("Invalid Model")
+ }
+ }
+ }
+ }
+
+ /** Union type for tool configurations in the tools array. */
+ @JsonDeserialize(using = Tool.Deserializer::class)
+ @JsonSerialize(using = Tool.Serializer::class)
+ class Tool
+ private constructor(
+ private val agentToolset20260401: BetaManagedAgentsAgentToolset20260401Params? = null,
+ private val mcpToolset: BetaManagedAgentsMcpToolsetParams? = null,
+ private val custom: BetaManagedAgentsCustomToolParams? = null,
+ private val _json: JsonValue? = null,
+ ) {
+
+ /**
+ * Configuration for built-in agent tools. Use this to enable or disable groups of tools
+ * available to the agent.
+ */
+ fun agentToolset20260401(): Optional =
+ Optional.ofNullable(agentToolset20260401)
+
+ /** Configuration for tools from an MCP server defined in `mcp_servers`. */
+ fun mcpToolset(): Optional =
+ Optional.ofNullable(mcpToolset)
+
+ /**
+ * A custom tool that is executed by the API client rather than the agent. When the agent
+ * calls this tool, an `agent.custom_tool_use` event is emitted and the session goes idle,
+ * waiting for the client to provide the result via a `user.custom_tool_result` event.
+ */
+ fun custom(): Optional = Optional.ofNullable(custom)
+
+ fun isAgentToolset20260401(): Boolean = agentToolset20260401 != null
+
+ fun isMcpToolset(): Boolean = mcpToolset != null
+
+ fun isCustom(): Boolean = custom != null
+
+ /**
+ * Configuration for built-in agent tools. Use this to enable or disable groups of tools
+ * available to the agent.
+ */
+ fun asAgentToolset20260401(): BetaManagedAgentsAgentToolset20260401Params =
+ agentToolset20260401.getOrThrow("agentToolset20260401")
+
+ /** Configuration for tools from an MCP server defined in `mcp_servers`. */
+ fun asMcpToolset(): BetaManagedAgentsMcpToolsetParams = mcpToolset.getOrThrow("mcpToolset")
+
+ /**
+ * A custom tool that is executed by the API client rather than the agent. When the agent
+ * calls this tool, an `agent.custom_tool_use` event is emitted and the session goes idle,
+ * waiting for the client to provide the result via a `user.custom_tool_result` event.
+ */
+ fun asCustom(): BetaManagedAgentsCustomToolParams = custom.getOrThrow("custom")
+
+ fun _json(): Optional = Optional.ofNullable(_json)
+
+ /**
+ * Maps this instance's current variant to a value of type [T] using the given [visitor].
+ *
+ * Note that this method is _not_ forwards compatible with new variants from the API, unless
+ * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of
+ * the SDK gracefully, consider overriding [Visitor.unknown]:
+ * ```java
+ * import com.anthropic.core.JsonValue;
+ * import java.util.Optional;
+ *
+ * Optional result = tool.accept(new Tool.Visitor>() {
+ * @Override
+ * public Optional visitAgentToolset20260401(BetaManagedAgentsAgentToolset20260401Params agentToolset20260401) {
+ * return Optional.of(agentToolset20260401.toString());
+ * }
+ *
+ * // ...
+ *
+ * @Override
+ * public Optional unknown(JsonValue json) {
+ * // Or inspect the `json`.
+ * return Optional.empty();
+ * }
+ * });
+ * ```
+ *
+ * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor]
+ * and the current variant is unknown.
+ */
+ fun accept(visitor: Visitor): T =
+ when {
+ agentToolset20260401 != null ->
+ visitor.visitAgentToolset20260401(agentToolset20260401)
+ mcpToolset != null -> visitor.visitMcpToolset(mcpToolset)
+ custom != null -> visitor.visitCustom(custom)
+ else -> visitor.unknown(_json)
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Tool = apply {
+ if (validated) {
+ return@apply
+ }
+
+ accept(
+ object : Visitor {
+ override fun visitAgentToolset20260401(
+ agentToolset20260401: BetaManagedAgentsAgentToolset20260401Params
+ ) {
+ agentToolset20260401.validate()
+ }
+
+ override fun visitMcpToolset(mcpToolset: BetaManagedAgentsMcpToolsetParams) {
+ mcpToolset.validate()
+ }
+
+ override fun visitCustom(custom: BetaManagedAgentsCustomToolParams) {
+ custom.validate()
+ }
+ }
+ )
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 =
+ accept(
+ object : Visitor {
+ override fun visitAgentToolset20260401(
+ agentToolset20260401: BetaManagedAgentsAgentToolset20260401Params
+ ) = agentToolset20260401.validity()
+
+ override fun visitMcpToolset(mcpToolset: BetaManagedAgentsMcpToolsetParams) =
+ mcpToolset.validity()
+
+ override fun visitCustom(custom: BetaManagedAgentsCustomToolParams) =
+ custom.validity()
+
+ override fun unknown(json: JsonValue?) = 0
+ }
+ )
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Tool &&
+ agentToolset20260401 == other.agentToolset20260401 &&
+ mcpToolset == other.mcpToolset &&
+ custom == other.custom
+ }
+
+ override fun hashCode(): Int = Objects.hash(agentToolset20260401, mcpToolset, custom)
+
+ override fun toString(): String =
+ when {
+ agentToolset20260401 != null -> "Tool{agentToolset20260401=$agentToolset20260401}"
+ mcpToolset != null -> "Tool{mcpToolset=$mcpToolset}"
+ custom != null -> "Tool{custom=$custom}"
+ _json != null -> "Tool{_unknown=$_json}"
+ else -> throw IllegalStateException("Invalid Tool")
+ }
+
+ companion object {
+
+ /**
+ * Configuration for built-in agent tools. Use this to enable or disable groups of tools
+ * available to the agent.
+ */
+ @JvmStatic
+ fun ofAgentToolset20260401(
+ agentToolset20260401: BetaManagedAgentsAgentToolset20260401Params
+ ) = Tool(agentToolset20260401 = agentToolset20260401)
+
+ /** Configuration for tools from an MCP server defined in `mcp_servers`. */
+ @JvmStatic
+ fun ofMcpToolset(mcpToolset: BetaManagedAgentsMcpToolsetParams) =
+ Tool(mcpToolset = mcpToolset)
+
+ /**
+ * A custom tool that is executed by the API client rather than the agent. When the
+ * agent calls this tool, an `agent.custom_tool_use` event is emitted and the session
+ * goes idle, waiting for the client to provide the result via a
+ * `user.custom_tool_result` event.
+ */
+ @JvmStatic
+ fun ofCustom(custom: BetaManagedAgentsCustomToolParams) = Tool(custom = custom)
+ }
+
+ /** An interface that defines how to map each variant of [Tool] to a value of type [T]. */
+ interface Visitor {
+
+ /**
+ * Configuration for built-in agent tools. Use this to enable or disable groups of tools
+ * available to the agent.
+ */
+ fun visitAgentToolset20260401(
+ agentToolset20260401: BetaManagedAgentsAgentToolset20260401Params
+ ): T
+
+ /** Configuration for tools from an MCP server defined in `mcp_servers`. */
+ fun visitMcpToolset(mcpToolset: BetaManagedAgentsMcpToolsetParams): T
+
+ /**
+ * A custom tool that is executed by the API client rather than the agent. When the
+ * agent calls this tool, an `agent.custom_tool_use` event is emitted and the session
+ * goes idle, waiting for the client to provide the result via a
+ * `user.custom_tool_result` event.
+ */
+ fun visitCustom(custom: BetaManagedAgentsCustomToolParams): T
+
+ /**
+ * Maps an unknown variant of [Tool] to a value of type [T].
+ *
+ * An instance of [Tool] can contain an unknown variant if it was deserialized from data
+ * that doesn't match any known variant. For example, if the SDK is on an older version
+ * than the API, then the API may respond with new variants that the SDK is unaware of.
+ *
+ * @throws AnthropicInvalidDataException in the default implementation.
+ */
+ fun unknown(json: JsonValue?): T {
+ throw AnthropicInvalidDataException("Unknown Tool: $json")
+ }
+ }
+
+ internal class Deserializer : BaseDeserializer(Tool::class) {
+
+ override fun ObjectCodec.deserialize(node: JsonNode): Tool {
+ val json = JsonValue.fromJsonNode(node)
+ val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull()
+
+ when (type) {
+ "agent_toolset_20260401" -> {
+ return tryDeserialize(
+ node,
+ jacksonTypeRef(),
+ )
+ ?.let { Tool(agentToolset20260401 = it, _json = json) }
+ ?: Tool(_json = json)
+ }
+ "mcp_toolset" -> {
+ return tryDeserialize(
+ node,
+ jacksonTypeRef(),
+ )
+ ?.let { Tool(mcpToolset = it, _json = json) } ?: Tool(_json = json)
+ }
+ "custom" -> {
+ return tryDeserialize(
+ node,
+ jacksonTypeRef(),
+ )
+ ?.let { Tool(custom = it, _json = json) } ?: Tool(_json = json)
+ }
+ }
+
+ return Tool(_json = json)
+ }
+ }
+
+ internal class Serializer : BaseSerializer(Tool::class) {
+
+ override fun serialize(
+ value: Tool,
+ generator: JsonGenerator,
+ provider: SerializerProvider,
+ ) {
+ when {
+ value.agentToolset20260401 != null ->
+ generator.writeObject(value.agentToolset20260401)
+ value.mcpToolset != null -> generator.writeObject(value.mcpToolset)
+ value.custom != null -> generator.writeObject(value.custom)
+ value._json != null -> generator.writeObject(value._json)
+ else -> throw IllegalStateException("Invalid Tool")
+ }
+ }
+ }
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsAgentWithOverridesParams &&
+ id == other.id &&
+ type == other.type &&
+ mcpServers == other.mcpServers &&
+ model == other.model &&
+ skills == other.skills &&
+ system == other.system &&
+ tools == other.tools &&
+ version == other.version &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ id,
+ type,
+ mcpServers,
+ model,
+ skills,
+ system,
+ tools,
+ version,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsAgentWithOverridesParams{id=$id, type=$type, mcpServers=$mcpServers, model=$model, skills=$skills, system=$system, tools=$tools, version=$version, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsDeltaContent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsDeltaContent.kt
new file mode 100644
index 000000000..bdf8f132d
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsDeltaContent.kt
@@ -0,0 +1,396 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkRequired
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import java.util.Collections
+import java.util.Objects
+import java.util.Optional
+import kotlin.jvm.optionals.getOrNull
+
+class BetaManagedAgentsDeltaContent
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val content: JsonField,
+ private val type: JsonField,
+ private val index: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("content")
+ @ExcludeMissing
+ content: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ @JsonProperty("index") @ExcludeMissing index: JsonField = JsonMissing.of(),
+ ) : this(content, type, index, mutableMapOf())
+
+ /**
+ * Regular text content.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun content(): BetaManagedAgentsTextBlock = content.getRequired("content")
+
+ /**
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun type(): Type = type.getRequired("type")
+
+ /**
+ * Which entry in the previewed event's content array this fragment lands in. Insert content as
+ * that entry when the index is new; append to the existing entry otherwise.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun index(): Optional = index.getOptional("index")
+
+ /**
+ * Returns the raw JSON value of [content].
+ *
+ * Unlike [content], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("content")
+ @ExcludeMissing
+ fun _content(): JsonField = content
+
+ /**
+ * Returns the raw JSON value of [type].
+ *
+ * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
+
+ /**
+ * Returns the raw JSON value of [index].
+ *
+ * Unlike [index], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of
+ * [BetaManagedAgentsDeltaContent].
+ *
+ * The following fields are required:
+ * ```java
+ * .content()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsDeltaContent]. */
+ class Builder internal constructor() {
+
+ private var content: JsonField? = null
+ private var type: JsonField? = null
+ private var index: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(betaManagedAgentsDeltaContent: BetaManagedAgentsDeltaContent) = apply {
+ content = betaManagedAgentsDeltaContent.content
+ type = betaManagedAgentsDeltaContent.type
+ index = betaManagedAgentsDeltaContent.index
+ additionalProperties = betaManagedAgentsDeltaContent.additionalProperties.toMutableMap()
+ }
+
+ /** Regular text content. */
+ fun content(content: BetaManagedAgentsTextBlock) = content(JsonField.of(content))
+
+ /**
+ * Sets [Builder.content] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.content] with a well-typed [BetaManagedAgentsTextBlock]
+ * value instead. This method is primarily for setting the field to an undocumented or not
+ * yet supported value.
+ */
+ fun content(content: JsonField) = apply {
+ this.content = content
+ }
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun type(type: JsonField) = apply { this.type = type }
+
+ /**
+ * Which entry in the previewed event's content array this fragment lands in. Insert content
+ * as that entry when the index is new; append to the existing entry otherwise.
+ */
+ fun index(index: Long) = index(JsonField.of(index))
+
+ /**
+ * Sets [Builder.index] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.index] with a well-typed [Long] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun index(index: JsonField) = apply { this.index = index }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [BetaManagedAgentsDeltaContent].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .content()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsDeltaContent =
+ BetaManagedAgentsDeltaContent(
+ checkRequired("content", content),
+ checkRequired("type", type),
+ index,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsDeltaContent = apply {
+ if (validated) {
+ return@apply
+ }
+
+ content().validate()
+ type().validate()
+ index()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 =
+ (content.asKnown().getOrNull()?.validity() ?: 0) +
+ (type.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (index.asKnown().isPresent) 1 else 0)
+
+ class Type @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 CONTENT_DELTA = of("content_delta")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ CONTENT_DELTA
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ CONTENT_DELTA,
+ /** An enum member indicating that [Type] 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) {
+ CONTENT_DELTA -> Value.CONTENT_DELTA
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ CONTENT_DELTA -> Known.CONTENT_DELTA
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsDeltaContent &&
+ content == other.content &&
+ type == other.type &&
+ index == other.index &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(content, type, index, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsDeltaContent{content=$content, type=$type, index=$index, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsDeltaEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsDeltaEvent.kt
new file mode 100644
index 000000000..21ac94c52
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsDeltaEvent.kt
@@ -0,0 +1,424 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkRequired
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+/**
+ * An incremental update to an event that is still being streamed. Deltas are best-effort and may
+ * stop early; when the buffered event with id == event_id is produced it carries the complete
+ * content. A model request that ends early (an error or interrupt) produces no buffered event — its
+ * terminal span.model_request_end closes the preview. Only sent on stream connections that opt in
+ * via event_deltas; never appears in event history.
+ */
+class BetaManagedAgentsDeltaEvent
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val delta: JsonField,
+ private val eventId: JsonField,
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("delta")
+ @ExcludeMissing
+ delta: JsonField = JsonMissing.of(),
+ @JsonProperty("event_id") @ExcludeMissing eventId: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ ) : this(delta, eventId, type, mutableMapOf())
+
+ /**
+ * One fragment of the previewed event. The delta type is named for the previewed event's field
+ * it streams into: agent.message events stream content_delta fragments, each a partial element
+ * of the content array.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun delta(): BetaManagedAgentsDeltaContent = delta.getRequired("delta")
+
+ /**
+ * The id of the event being previewed. Matches event.id on the corresponding event_start and
+ * the buffered event that reconciles the preview.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun eventId(): String = eventId.getRequired("event_id")
+
+ /**
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun type(): Type = type.getRequired("type")
+
+ /**
+ * Returns the raw JSON value of [delta].
+ *
+ * Unlike [delta], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("delta")
+ @ExcludeMissing
+ fun _delta(): JsonField = delta
+
+ /**
+ * Returns the raw JSON value of [eventId].
+ *
+ * Unlike [eventId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId
+
+ /**
+ * Returns the raw JSON value of [type].
+ *
+ * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [BetaManagedAgentsDeltaEvent].
+ *
+ * The following fields are required:
+ * ```java
+ * .delta()
+ * .eventId()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsDeltaEvent]. */
+ class Builder internal constructor() {
+
+ private var delta: JsonField? = null
+ private var eventId: JsonField? = null
+ private var type: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(betaManagedAgentsDeltaEvent: BetaManagedAgentsDeltaEvent) = apply {
+ delta = betaManagedAgentsDeltaEvent.delta
+ eventId = betaManagedAgentsDeltaEvent.eventId
+ type = betaManagedAgentsDeltaEvent.type
+ additionalProperties = betaManagedAgentsDeltaEvent.additionalProperties.toMutableMap()
+ }
+
+ /**
+ * One fragment of the previewed event. The delta type is named for the previewed event's
+ * field it streams into: agent.message events stream content_delta fragments, each a
+ * partial element of the content array.
+ */
+ fun delta(delta: BetaManagedAgentsDeltaContent) = delta(JsonField.of(delta))
+
+ /**
+ * Sets [Builder.delta] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.delta] with a well-typed [BetaManagedAgentsDeltaContent]
+ * value instead. This method is primarily for setting the field to an undocumented or not
+ * yet supported value.
+ */
+ fun delta(delta: JsonField) = apply { this.delta = delta }
+
+ /**
+ * Alias for calling [delta] with the following:
+ * ```java
+ * BetaManagedAgentsDeltaContent.builder()
+ * .type(BetaManagedAgentsDeltaContent.Type.CONTENT_DELTA)
+ * .content(content)
+ * .build()
+ * ```
+ */
+ fun contentDeltaDelta(content: BetaManagedAgentsTextBlock) =
+ delta(
+ BetaManagedAgentsDeltaContent.builder()
+ .type(BetaManagedAgentsDeltaContent.Type.CONTENT_DELTA)
+ .content(content)
+ .build()
+ )
+
+ /**
+ * The id of the event being previewed. Matches event.id on the corresponding event_start
+ * and the buffered event that reconciles the preview.
+ */
+ fun eventId(eventId: String) = eventId(JsonField.of(eventId))
+
+ /**
+ * Sets [Builder.eventId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.eventId] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun eventId(eventId: JsonField) = apply { this.eventId = eventId }
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun type(type: JsonField) = apply { this.type = type }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [BetaManagedAgentsDeltaEvent].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .delta()
+ * .eventId()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsDeltaEvent =
+ BetaManagedAgentsDeltaEvent(
+ checkRequired("delta", delta),
+ checkRequired("eventId", eventId),
+ checkRequired("type", type),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsDeltaEvent = apply {
+ if (validated) {
+ return@apply
+ }
+
+ delta().validate()
+ eventId()
+ type().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 =
+ (delta.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (eventId.asKnown().isPresent) 1 else 0) +
+ (type.asKnown().getOrNull()?.validity() ?: 0)
+
+ class Type @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 EVENT_DELTA = of("event_delta")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ EVENT_DELTA
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ EVENT_DELTA,
+ /** An enum member indicating that [Type] 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) {
+ EVENT_DELTA -> Value.EVENT_DELTA
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ EVENT_DELTA -> Known.EVENT_DELTA
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsDeltaEvent &&
+ delta == other.delta &&
+ eventId == other.eventId &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(delta, eventId, type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsDeltaEvent{delta=$delta, eventId=$eventId, type=$type, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsDeltaType.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsDeltaType.kt
new file mode 100644
index 000000000..c4a8f97be
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsDeltaType.kt
@@ -0,0 +1,147 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.Enum
+import com.anthropic.core.JsonField
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.fasterxml.jackson.annotation.JsonCreator
+
+/** EventDeltaType enum */
+class BetaManagedAgentsDeltaType
+@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 AGENT_MESSAGE = of("agent.message")
+
+ @JvmField val AGENT_THINKING = of("agent.thinking")
+
+ @JvmStatic fun of(value: String) = BetaManagedAgentsDeltaType(JsonField.of(value))
+ }
+
+ /** An enum containing [BetaManagedAgentsDeltaType]'s known values. */
+ enum class Known {
+ AGENT_MESSAGE,
+ AGENT_THINKING,
+ }
+
+ /**
+ * An enum containing [BetaManagedAgentsDeltaType]'s known values, as well as an [_UNKNOWN]
+ * member.
+ *
+ * An instance of [BetaManagedAgentsDeltaType] 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 {
+ AGENT_MESSAGE,
+ AGENT_THINKING,
+ /**
+ * An enum member indicating that [BetaManagedAgentsDeltaType] 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) {
+ AGENT_MESSAGE -> Value.AGENT_MESSAGE
+ AGENT_THINKING -> Value.AGENT_THINKING
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known member.
+ */
+ fun known(): Known =
+ when (this) {
+ AGENT_MESSAGE -> Known.AGENT_MESSAGE
+ AGENT_THINKING -> Known.AGENT_THINKING
+ else ->
+ throw AnthropicInvalidDataException("Unknown BetaManagedAgentsDeltaType: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow { AnthropicInvalidDataException("Value is not a String") }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsDeltaType = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 BetaManagedAgentsDeltaType && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsStartEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsStartEvent.kt
new file mode 100644
index 000000000..2704f9cac
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsStartEvent.kt
@@ -0,0 +1,418 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.Enum
+import com.anthropic.core.ExcludeMissing
+import com.anthropic.core.JsonField
+import com.anthropic.core.JsonMissing
+import com.anthropic.core.JsonValue
+import com.anthropic.core.checkRequired
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import java.util.Collections
+import java.util.Objects
+import kotlin.jvm.optionals.getOrNull
+
+/**
+ * Opens a preview of a buffered event. Carries the previewed event's type and id only. Followed by
+ * zero or more event_delta events with the same event id, normally concluded by the buffered event
+ * carrying that id. If the producing model request ends without that event (an error or interrupt
+ * mid-stream), its terminal span.model_request_end closes the preview. Only sent on stream
+ * connections that opt in via event_deltas; never appears in event history.
+ */
+class BetaManagedAgentsStartEvent
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val event: JsonField,
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("event")
+ @ExcludeMissing
+ event: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ ) : this(event, type, mutableMapOf())
+
+ /**
+ * The previewed event's type and id. The event type determines which delta types the preview's
+ * event_delta events carry: agent.message events stream content_delta fragments; agent.thinking
+ * previews are start-only — no deltas follow, and the buffered agent.thinking with the same id
+ * concludes them.
+ *
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun event(): BetaManagedAgentsStartEventPreview = event.getRequired("event")
+
+ /**
+ * @throws AnthropicInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun type(): Type = type.getRequired("type")
+
+ /**
+ * Returns the raw JSON value of [event].
+ *
+ * Unlike [event], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("event")
+ @ExcludeMissing
+ fun _event(): JsonField = event
+
+ /**
+ * Returns the raw JSON value of [type].
+ *
+ * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [BetaManagedAgentsStartEvent].
+ *
+ * The following fields are required:
+ * ```java
+ * .event()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [BetaManagedAgentsStartEvent]. */
+ class Builder internal constructor() {
+
+ private var event: JsonField? = null
+ private var type: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(betaManagedAgentsStartEvent: BetaManagedAgentsStartEvent) = apply {
+ event = betaManagedAgentsStartEvent.event
+ type = betaManagedAgentsStartEvent.type
+ additionalProperties = betaManagedAgentsStartEvent.additionalProperties.toMutableMap()
+ }
+
+ /**
+ * The previewed event's type and id. The event type determines which delta types the
+ * preview's event_delta events carry: agent.message events stream content_delta fragments;
+ * agent.thinking previews are start-only — no deltas follow, and the buffered
+ * agent.thinking with the same id concludes them.
+ */
+ fun event(event: BetaManagedAgentsStartEventPreview) = event(JsonField.of(event))
+
+ /**
+ * Sets [Builder.event] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.event] with a well-typed
+ * [BetaManagedAgentsStartEventPreview] value instead. This method is primarily for setting
+ * the field to an undocumented or not yet supported value.
+ */
+ fun event(event: JsonField) = apply {
+ this.event = event
+ }
+
+ /**
+ * Alias for calling [event] with
+ * `BetaManagedAgentsStartEventPreview.ofAgentMessage(agentMessage)`.
+ */
+ fun event(agentMessage: BetaManagedAgentsAgentMessagePreview) =
+ event(BetaManagedAgentsStartEventPreview.ofAgentMessage(agentMessage))
+
+ /**
+ * Alias for calling [event] with the following:
+ * ```java
+ * BetaManagedAgentsAgentMessagePreview.builder()
+ * .type(BetaManagedAgentsAgentMessagePreview.Type.AGENT_MESSAGE)
+ * .id(id)
+ * .build()
+ * ```
+ */
+ fun agentMessageEvent(id: String) =
+ event(
+ BetaManagedAgentsAgentMessagePreview.builder()
+ .type(BetaManagedAgentsAgentMessagePreview.Type.AGENT_MESSAGE)
+ .id(id)
+ .build()
+ )
+
+ /**
+ * Alias for calling [event] with
+ * `BetaManagedAgentsStartEventPreview.ofAgentThinking(agentThinking)`.
+ */
+ fun event(agentThinking: BetaManagedAgentsAgentThinkingPreview) =
+ event(BetaManagedAgentsStartEventPreview.ofAgentThinking(agentThinking))
+
+ /**
+ * Alias for calling [event] with the following:
+ * ```java
+ * BetaManagedAgentsAgentThinkingPreview.builder()
+ * .type(BetaManagedAgentsAgentThinkingPreview.Type.AGENT_THINKING)
+ * .id(id)
+ * .build()
+ * ```
+ */
+ fun agentThinkingEvent(id: String) =
+ event(
+ BetaManagedAgentsAgentThinkingPreview.builder()
+ .type(BetaManagedAgentsAgentThinkingPreview.Type.AGENT_THINKING)
+ .id(id)
+ .build()
+ )
+
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun type(type: JsonField) = apply { this.type = type }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [BetaManagedAgentsStartEvent].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .event()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): BetaManagedAgentsStartEvent =
+ BetaManagedAgentsStartEvent(
+ checkRequired("event", event),
+ checkRequired("type", type),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsStartEvent = apply {
+ if (validated) {
+ return@apply
+ }
+
+ event().validate()
+ type().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 =
+ (event.asKnown().getOrNull()?.validity() ?: 0) +
+ (type.asKnown().getOrNull()?.validity() ?: 0)
+
+ class Type @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 EVENT_START = of("event_start")
+
+ @JvmStatic fun of(value: String) = Type(JsonField.of(value))
+ }
+
+ /** An enum containing [Type]'s known values. */
+ enum class Known {
+ EVENT_START
+ }
+
+ /**
+ * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [Type] 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 {
+ EVENT_START,
+ /** An enum member indicating that [Type] 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) {
+ EVENT_START -> Value.EVENT_START
+ 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 AnthropicInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ EVENT_START -> Known.EVENT_START
+ else -> throw AnthropicInvalidDataException("Unknown Type: $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 AnthropicInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ AnthropicInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Type = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 Type && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsStartEvent &&
+ event == other.event &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(event, type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "BetaManagedAgentsStartEvent{event=$event, type=$type, additionalProperties=$additionalProperties}"
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsStartEventPreview.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsStartEventPreview.kt
new file mode 100644
index 000000000..2349d5cc5
--- /dev/null
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsStartEventPreview.kt
@@ -0,0 +1,252 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.anthropic.models.beta.sessions
+
+import com.anthropic.core.BaseDeserializer
+import com.anthropic.core.BaseSerializer
+import com.anthropic.core.JsonValue
+import com.anthropic.core.getOrThrow
+import com.anthropic.errors.AnthropicInvalidDataException
+import com.fasterxml.jackson.core.JsonGenerator
+import com.fasterxml.jackson.core.ObjectCodec
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.SerializerProvider
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize
+import com.fasterxml.jackson.databind.annotation.JsonSerialize
+import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
+import java.util.Objects
+import java.util.Optional
+import kotlin.jvm.optionals.getOrNull
+
+@JsonDeserialize(using = BetaManagedAgentsStartEventPreview.Deserializer::class)
+@JsonSerialize(using = BetaManagedAgentsStartEventPreview.Serializer::class)
+class BetaManagedAgentsStartEventPreview
+private constructor(
+ private val agentMessage: BetaManagedAgentsAgentMessagePreview? = null,
+ private val agentThinking: BetaManagedAgentsAgentThinkingPreview? = null,
+ private val _json: JsonValue? = null,
+) {
+
+ fun agentMessage(): Optional =
+ Optional.ofNullable(agentMessage)
+
+ fun agentThinking(): Optional =
+ Optional.ofNullable(agentThinking)
+
+ fun isAgentMessage(): Boolean = agentMessage != null
+
+ fun isAgentThinking(): Boolean = agentThinking != null
+
+ fun asAgentMessage(): BetaManagedAgentsAgentMessagePreview =
+ agentMessage.getOrThrow("agentMessage")
+
+ fun asAgentThinking(): BetaManagedAgentsAgentThinkingPreview =
+ agentThinking.getOrThrow("agentThinking")
+
+ fun _json(): Optional = Optional.ofNullable(_json)
+
+ /**
+ * Maps this instance's current variant to a value of type [T] using the given [visitor].
+ *
+ * Note that this method is _not_ forwards compatible with new variants from the API, unless
+ * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the
+ * SDK gracefully, consider overriding [Visitor.unknown]:
+ * ```java
+ * import com.anthropic.core.JsonValue;
+ * import java.util.Optional;
+ *
+ * Optional result = betaManagedAgentsStartEventPreview.accept(new BetaManagedAgentsStartEventPreview.Visitor>() {
+ * @Override
+ * public Optional visitAgentMessage(BetaManagedAgentsAgentMessagePreview agentMessage) {
+ * return Optional.of(agentMessage.toString());
+ * }
+ *
+ * // ...
+ *
+ * @Override
+ * public Optional unknown(JsonValue json) {
+ * // Or inspect the `json`.
+ * return Optional.empty();
+ * }
+ * });
+ * ```
+ *
+ * @throws AnthropicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and
+ * the current variant is unknown.
+ */
+ fun accept(visitor: Visitor): T =
+ when {
+ agentMessage != null -> visitor.visitAgentMessage(agentMessage)
+ agentThinking != null -> visitor.visitAgentThinking(agentThinking)
+ else -> visitor.unknown(_json)
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws AnthropicInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): BetaManagedAgentsStartEventPreview = apply {
+ if (validated) {
+ return@apply
+ }
+
+ accept(
+ object : Visitor {
+ override fun visitAgentMessage(agentMessage: BetaManagedAgentsAgentMessagePreview) {
+ agentMessage.validate()
+ }
+
+ override fun visitAgentThinking(
+ agentThinking: BetaManagedAgentsAgentThinkingPreview
+ ) {
+ agentThinking.validate()
+ }
+ }
+ )
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: AnthropicInvalidDataException) {
+ 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 =
+ accept(
+ object : Visitor {
+ override fun visitAgentMessage(agentMessage: BetaManagedAgentsAgentMessagePreview) =
+ agentMessage.validity()
+
+ override fun visitAgentThinking(
+ agentThinking: BetaManagedAgentsAgentThinkingPreview
+ ) = agentThinking.validity()
+
+ override fun unknown(json: JsonValue?) = 0
+ }
+ )
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is BetaManagedAgentsStartEventPreview &&
+ agentMessage == other.agentMessage &&
+ agentThinking == other.agentThinking
+ }
+
+ override fun hashCode(): Int = Objects.hash(agentMessage, agentThinking)
+
+ override fun toString(): String =
+ when {
+ agentMessage != null -> "BetaManagedAgentsStartEventPreview{agentMessage=$agentMessage}"
+ agentThinking != null ->
+ "BetaManagedAgentsStartEventPreview{agentThinking=$agentThinking}"
+ _json != null -> "BetaManagedAgentsStartEventPreview{_unknown=$_json}"
+ else -> throw IllegalStateException("Invalid BetaManagedAgentsStartEventPreview")
+ }
+
+ companion object {
+
+ @JvmStatic
+ fun ofAgentMessage(agentMessage: BetaManagedAgentsAgentMessagePreview) =
+ BetaManagedAgentsStartEventPreview(agentMessage = agentMessage)
+
+ @JvmStatic
+ fun ofAgentThinking(agentThinking: BetaManagedAgentsAgentThinkingPreview) =
+ BetaManagedAgentsStartEventPreview(agentThinking = agentThinking)
+ }
+
+ /**
+ * An interface that defines how to map each variant of [BetaManagedAgentsStartEventPreview] to
+ * a value of type [T].
+ */
+ interface Visitor {
+
+ fun visitAgentMessage(agentMessage: BetaManagedAgentsAgentMessagePreview): T
+
+ fun visitAgentThinking(agentThinking: BetaManagedAgentsAgentThinkingPreview): T
+
+ /**
+ * Maps an unknown variant of [BetaManagedAgentsStartEventPreview] to a value of type [T].
+ *
+ * An instance of [BetaManagedAgentsStartEventPreview] can contain an unknown variant if it
+ * was deserialized from data that doesn't match any known variant. For example, if the SDK
+ * is on an older version than the API, then the API may respond with new variants that the
+ * SDK is unaware of.
+ *
+ * @throws AnthropicInvalidDataException in the default implementation.
+ */
+ fun unknown(json: JsonValue?): T {
+ throw AnthropicInvalidDataException("Unknown BetaManagedAgentsStartEventPreview: $json")
+ }
+ }
+
+ internal class Deserializer :
+ BaseDeserializer(
+ BetaManagedAgentsStartEventPreview::class
+ ) {
+
+ override fun ObjectCodec.deserialize(node: JsonNode): BetaManagedAgentsStartEventPreview {
+ val json = JsonValue.fromJsonNode(node)
+ val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull()
+
+ when (type) {
+ "agent.message" -> {
+ return tryDeserialize(
+ node,
+ jacksonTypeRef(),
+ )
+ ?.let {
+ BetaManagedAgentsStartEventPreview(agentMessage = it, _json = json)
+ } ?: BetaManagedAgentsStartEventPreview(_json = json)
+ }
+ "agent.thinking" -> {
+ return tryDeserialize(
+ node,
+ jacksonTypeRef(),
+ )
+ ?.let {
+ BetaManagedAgentsStartEventPreview(agentThinking = it, _json = json)
+ } ?: BetaManagedAgentsStartEventPreview(_json = json)
+ }
+ }
+
+ return BetaManagedAgentsStartEventPreview(_json = json)
+ }
+ }
+
+ internal class Serializer :
+ BaseSerializer(
+ BetaManagedAgentsStartEventPreview::class
+ ) {
+
+ override fun serialize(
+ value: BetaManagedAgentsStartEventPreview,
+ generator: JsonGenerator,
+ provider: SerializerProvider,
+ ) {
+ when {
+ value.agentMessage != null -> generator.writeObject(value.agentMessage)
+ value.agentThinking != null -> generator.writeObject(value.agentThinking)
+ value._json != null -> generator.writeObject(value._json)
+ else -> throw IllegalStateException("Invalid BetaManagedAgentsStartEventPreview")
+ }
+ }
+ }
+}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionCreateParams.kt
index 6484271e1..052287248 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionCreateParams.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionCreateParams.kt
@@ -241,6 +241,14 @@ private constructor(
body.agent(betaManagedAgentsAgentParams)
}
+ /**
+ * Alias for calling [agent] with
+ * `Agent.ofBetaManagedAgentsAgentWithOverridesParams(betaManagedAgentsAgentWithOverridesParams)`.
+ */
+ fun agent(
+ betaManagedAgentsAgentWithOverridesParams: BetaManagedAgentsAgentWithOverridesParams
+ ) = apply { body.agent(betaManagedAgentsAgentWithOverridesParams) }
+
/** ID of the `environment` defining the container configuration for this session. */
fun environmentId(environmentId: String) = apply { body.environmentId(environmentId) }
@@ -715,6 +723,19 @@ private constructor(
fun agent(betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams) =
agent(Agent.ofBetaManagedAgentsAgentParams(betaManagedAgentsAgentParams))
+ /**
+ * Alias for calling [agent] with
+ * `Agent.ofBetaManagedAgentsAgentWithOverridesParams(betaManagedAgentsAgentWithOverridesParams)`.
+ */
+ fun agent(
+ betaManagedAgentsAgentWithOverridesParams: BetaManagedAgentsAgentWithOverridesParams
+ ) =
+ agent(
+ Agent.ofBetaManagedAgentsAgentWithOverridesParams(
+ betaManagedAgentsAgentWithOverridesParams
+ )
+ )
+
/** ID of the `environment` defining the container configuration for this session. */
fun environmentId(environmentId: String) = environmentId(JsonField.of(environmentId))
@@ -994,6 +1015,9 @@ private constructor(
private constructor(
private val string: String? = null,
private val betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams? = null,
+ private val betaManagedAgentsAgentWithOverridesParams:
+ BetaManagedAgentsAgentWithOverridesParams? =
+ null,
private val _json: JsonValue? = null,
) {
@@ -1006,10 +1030,21 @@ private constructor(
fun betaManagedAgentsAgentParams(): Optional =
Optional.ofNullable(betaManagedAgentsAgentParams)
+ /**
+ * Reference to an `agent` plus optional configuration overrides. Each provided field
+ * replaces the agent's value for the caller's use; the agent resource is unchanged.
+ */
+ fun betaManagedAgentsAgentWithOverridesParams():
+ Optional =
+ Optional.ofNullable(betaManagedAgentsAgentWithOverridesParams)
+
fun isString(): Boolean = string != null
fun isBetaManagedAgentsAgentParams(): Boolean = betaManagedAgentsAgentParams != null
+ fun isBetaManagedAgentsAgentWithOverridesParams(): Boolean =
+ betaManagedAgentsAgentWithOverridesParams != null
+
fun asString(): String = string.getOrThrow("string")
/**
@@ -1019,6 +1054,16 @@ private constructor(
fun asBetaManagedAgentsAgentParams(): BetaManagedAgentsAgentParams =
betaManagedAgentsAgentParams.getOrThrow("betaManagedAgentsAgentParams")
+ /**
+ * Reference to an `agent` plus optional configuration overrides. Each provided field
+ * replaces the agent's value for the caller's use; the agent resource is unchanged.
+ */
+ fun asBetaManagedAgentsAgentWithOverridesParams():
+ BetaManagedAgentsAgentWithOverridesParams =
+ betaManagedAgentsAgentWithOverridesParams.getOrThrow(
+ "betaManagedAgentsAgentWithOverridesParams"
+ )
+
fun _json(): Optional = Optional.ofNullable(_json)
/**
@@ -1055,6 +1100,10 @@ private constructor(
string != null -> visitor.visitString(string)
betaManagedAgentsAgentParams != null ->
visitor.visitBetaManagedAgentsAgentParams(betaManagedAgentsAgentParams)
+ betaManagedAgentsAgentWithOverridesParams != null ->
+ visitor.visitBetaManagedAgentsAgentWithOverridesParams(
+ betaManagedAgentsAgentWithOverridesParams
+ )
else -> visitor.unknown(_json)
}
@@ -1083,6 +1132,13 @@ private constructor(
) {
betaManagedAgentsAgentParams.validate()
}
+
+ override fun visitBetaManagedAgentsAgentWithOverridesParams(
+ betaManagedAgentsAgentWithOverridesParams:
+ BetaManagedAgentsAgentWithOverridesParams
+ ) {
+ betaManagedAgentsAgentWithOverridesParams.validate()
+ }
}
)
validated = true
@@ -1112,6 +1168,11 @@ private constructor(
betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams
) = betaManagedAgentsAgentParams.validity()
+ override fun visitBetaManagedAgentsAgentWithOverridesParams(
+ betaManagedAgentsAgentWithOverridesParams:
+ BetaManagedAgentsAgentWithOverridesParams
+ ) = betaManagedAgentsAgentWithOverridesParams.validity()
+
override fun unknown(json: JsonValue?) = 0
}
)
@@ -1123,16 +1184,25 @@ private constructor(
return other is Agent &&
string == other.string &&
- betaManagedAgentsAgentParams == other.betaManagedAgentsAgentParams
+ betaManagedAgentsAgentParams == other.betaManagedAgentsAgentParams &&
+ betaManagedAgentsAgentWithOverridesParams ==
+ other.betaManagedAgentsAgentWithOverridesParams
}
- override fun hashCode(): Int = Objects.hash(string, betaManagedAgentsAgentParams)
+ override fun hashCode(): Int =
+ Objects.hash(
+ string,
+ betaManagedAgentsAgentParams,
+ betaManagedAgentsAgentWithOverridesParams,
+ )
override fun toString(): String =
when {
string != null -> "Agent{string=$string}"
betaManagedAgentsAgentParams != null ->
"Agent{betaManagedAgentsAgentParams=$betaManagedAgentsAgentParams}"
+ betaManagedAgentsAgentWithOverridesParams != null ->
+ "Agent{betaManagedAgentsAgentWithOverridesParams=$betaManagedAgentsAgentWithOverridesParams}"
_json != null -> "Agent{_unknown=$_json}"
else -> throw IllegalStateException("Invalid Agent")
}
@@ -1149,6 +1219,19 @@ private constructor(
fun ofBetaManagedAgentsAgentParams(
betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams
) = Agent(betaManagedAgentsAgentParams = betaManagedAgentsAgentParams)
+
+ /**
+ * Reference to an `agent` plus optional configuration overrides. Each provided field
+ * replaces the agent's value for the caller's use; the agent resource is unchanged.
+ */
+ @JvmStatic
+ fun ofBetaManagedAgentsAgentWithOverridesParams(
+ betaManagedAgentsAgentWithOverridesParams: BetaManagedAgentsAgentWithOverridesParams
+ ) =
+ Agent(
+ betaManagedAgentsAgentWithOverridesParams =
+ betaManagedAgentsAgentWithOverridesParams
+ )
}
/** An interface that defines how to map each variant of [Agent] to a value of type [T]. */
@@ -1164,6 +1247,14 @@ private constructor(
betaManagedAgentsAgentParams: BetaManagedAgentsAgentParams
): T
+ /**
+ * Reference to an `agent` plus optional configuration overrides. Each provided field
+ * replaces the agent's value for the caller's use; the agent resource is unchanged.
+ */
+ fun visitBetaManagedAgentsAgentWithOverridesParams(
+ betaManagedAgentsAgentWithOverridesParams: BetaManagedAgentsAgentWithOverridesParams
+ ): T
+
/**
* Maps an unknown variant of [Agent] to a value of type [T].
*
@@ -1188,6 +1279,16 @@ private constructor(
sequenceOf(
tryDeserialize(node, jacksonTypeRef())
?.let { Agent(betaManagedAgentsAgentParams = it, _json = json) },
+ tryDeserialize(
+ node,
+ jacksonTypeRef(),
+ )
+ ?.let {
+ Agent(
+ betaManagedAgentsAgentWithOverridesParams = it,
+ _json = json,
+ )
+ },
tryDeserialize(node, jacksonTypeRef())?.let {
Agent(string = it, _json = json)
},
@@ -1219,6 +1320,8 @@ private constructor(
value.string != null -> generator.writeObject(value.string)
value.betaManagedAgentsAgentParams != null ->
generator.writeObject(value.betaManagedAgentsAgentParams)
+ value.betaManagedAgentsAgentWithOverridesParams != null ->
+ generator.writeObject(value.betaManagedAgentsAgentWithOverridesParams)
value._json != null -> generator.writeObject(value._json)
else -> throw IllegalStateException("Invalid Agent")
}
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPage.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPage.kt
index 9c9121f4c..ed2539181 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPage.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPage.kt
@@ -33,6 +33,13 @@ private constructor(
*/
fun nextPageRaw(): Optional = response._nextPage().getOptional("next_page")
+ /**
+ * Delegates to [SessionListPageResponse], but gracefully handles missing data.
+ *
+ * @see SessionListPageResponse.prevPage
+ */
+ fun prevPage(): Optional = response._prevPage().getOptional("prev_page")
+
override fun items(): List = data()
override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageRaw().isPresent
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPageAsync.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPageAsync.kt
index 71a73d0f9..df11afafc 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPageAsync.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPageAsync.kt
@@ -36,6 +36,13 @@ private constructor(
*/
fun nextPageRaw(): Optional = response._nextPage().getOptional("next_page")
+ /**
+ * Delegates to [SessionListPageResponse], but gracefully handles missing data.
+ *
+ * @see SessionListPageResponse.prevPage
+ */
+ fun prevPage(): Optional = response._prevPage().getOptional("prev_page")
+
override fun items(): List = data()
override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageRaw().isPresent
diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponse.kt
index f22d36ef0..41239031d 100644
--- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponse.kt
+++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponse.kt
@@ -24,6 +24,7 @@ class SessionListPageResponse
private constructor(
private val data: JsonField>,
private val nextPage: JsonField,
+ private val prevPage: JsonField