Skip to content

Commit f41a324

Browse files
feat(api): add support for claude-fable-5-1 and claude-mythos-5-1
Also adds per-message `output_config` (effort) and `clear_at` on system messages, and the thinking-block binding controls (beta). Stainless-Generated-From: bf315983c668a6b1f0101c8b7df10e4e44f1a2aa
1 parent 04045b5 commit f41a324

61 files changed

Lines changed: 3203 additions & 132 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

anthropic-java-core/src/main/kotlin/com/anthropic/helpers/BetaMessageAccumulator.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ class BetaMessageAccumulator private constructor() {
311311
.contextManagement(messageDelta.contextManagement().get())
312312
}
313313

314+
// Only sent on `message_delta` after a mid-stream model fallback, in which case
315+
// it replaces the value from `message_start`.
316+
if (messageDelta.inputTransformations().isPresent) {
317+
requireMessageBuilder()
318+
.inputTransformations(messageDelta.inputTransformations().get())
319+
}
320+
314321
messageUsage = mergeMessageUsage(requireMessageUsage(), messageDelta.usage())
315322
}
316323

anthropic-java-core/src/main/kotlin/com/anthropic/helpers/BetaRefusalFallbackInterceptor.kt

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,8 @@ private class FallbackStreamSplicer(
10951095
* The initial stream (`splice == null`) is forwarded in its original wire bytes; a spliced hop
10961096
* (`splice` set) has its message_start suppressed (the client already saw the initial one), its
10971097
* block indices shifted by [indexBase], and its terminal message_delta's usage rewritten to the
1098-
* `usage.iterations` chain shape.
1098+
* `usage.iterations` chain shape, with that message_start's `input_transformations` copied onto
1099+
* it.
10991100
*
11001101
* A refusal that can be chained — it carries a `fallback_credit_token` and a fallback entry
11011102
* remains — ends the hop early: open blocks are closed, the terminal message_delta +
@@ -1114,6 +1115,9 @@ private class FallbackStreamSplicer(
11141115
val tracker = BlockTracker(indexBase)
11151116
var model: String? = null
11161117
var startUsage: ObjectNode? = null
1118+
// `input_transformations` from a spliced fallback's `message_start`, which is not
1119+
// re-emitted. Copied onto the emitted message_delta, as a server-side fallback does.
1120+
var startInputTransformations: JsonNode? = null
11171121

11181122
rawSseHandler(jsonMapper).handle(response).use { sseStream ->
11191123
events@ for (sse in sseStream.stream().asSequence()) {
@@ -1143,6 +1147,10 @@ private class FallbackStreamSplicer(
11431147
message?._usage()?.asKnown()?.getOrNull()?.let {
11441148
jsonMapper.valueToTree<ObjectNode>(it)
11451149
}
1150+
val startMessage = event.path("message")
1151+
if (startMessage.has("input_transformations")) {
1152+
startInputTransformations = startMessage.get("input_transformations")
1153+
}
11461154
if (splice != null) {
11471155
continue@events
11481156
}
@@ -1199,6 +1207,7 @@ private class FallbackStreamSplicer(
11991207
deltaEvent,
12001208
delta,
12011209
details,
1210+
startInputTransformations.takeIf { splice != null },
12021211
),
12031212
model,
12041213
tracker.blocks,
@@ -1229,6 +1238,12 @@ private class FallbackStreamSplicer(
12291238
chain.add(entry)
12301239
usage.set<JsonNode>("iterations", chain)
12311240
event.set<JsonNode>("usage", usage)
1241+
val inputTransformations = startInputTransformations
1242+
if (
1243+
!event.has("input_transformations") && inputTransformations != null
1244+
) {
1245+
event.set<JsonNode>("input_transformations", inputTransformations)
1246+
}
12321247
yield(emit(event))
12331248
continue@events
12341249
}
@@ -1317,9 +1332,8 @@ private class FallbackStreamSplicer(
13171332
* `recommended_model` pointed at the hop last tried and its usage backfilled from its
13181333
* message_start (injected raw: the merged usage is the wire shape, not a typed value).
13191334
*/
1320-
private fun heldRefusalDelta(refusal: Refusal, recommendedModel: String): ByteArray =
1321-
emit(
1322-
"message_delta",
1335+
private fun heldRefusalDelta(refusal: Refusal, recommendedModel: String): ByteArray {
1336+
val builder =
13231337
refusal.event
13241338
.toBuilder()
13251339
.delta(
@@ -1331,8 +1345,14 @@ private class FallbackStreamSplicer(
13311345
.build()
13321346
)
13331347
.usage(JsonValue.fromJsonNode(refusal.usage))
1334-
.build(),
1335-
)
1348+
// The spliced fallback's message_start was not re-emitted, so copy its
1349+
// `input_transformations` onto this delta unless the delta already has its own.
1350+
val inputTransformations = refusal.inputTransformations
1351+
if (inputTransformations != null && refusal.event._inputTransformations().isMissing()) {
1352+
builder.inputTransformations(JsonValue.fromJsonNode(inputTransformations))
1353+
}
1354+
return emit("message_delta", builder.build())
1355+
}
13361356

13371357
private fun messageStop(): ByteArray =
13381358
emit("message_stop", BetaRawMessageStopEvent.builder().build())
@@ -1434,6 +1454,12 @@ private class FallbackStreamSplicer(
14341454
/** [event]'s delta and refusal stop details, rebuilt into it when it's surfaced. */
14351455
val delta: BetaRawMessageDeltaEvent.Delta,
14361456
val details: BetaRefusalStopDetails,
1457+
/**
1458+
* The `input_transformations` from a spliced fallback hop's suppressed `message_start`
1459+
* event. Retained so the field can be forwarded onto the replayed refusal `message_delta`
1460+
* event ([event]); `null` for the initial stream.
1461+
*/
1462+
val inputTransformations: JsonNode?,
14371463
)
14381464

14391465
/** A response content block being accumulated from its streaming deltas. */

anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/AnthropicBeta.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ class AnthropicBeta @JsonCreator private constructor(private val value: JsonFiel
108108

109109
@JvmField val CE_USER_MANAGEMENT_2026_07_13 = of("ce-user-management-2026-07-13")
110110

111+
@JvmField
112+
val MID_CONVERSATION_OUTPUT_CONFIG_2026_07_01 =
113+
of("mid-conversation-output-config-2026-07-01")
114+
115+
@JvmField
116+
val THINKING_BINDING_CONTROLS_2026_08_01 = of("thinking-binding-controls-2026-08-01")
117+
118+
@JvmField
119+
val MID_CONVERSATION_SYSTEM_CLEAR_AT_2026_08_21 =
120+
of("mid-conversation-system-clear-at-2026-08-21")
121+
111122
@JvmStatic fun of(value: String) = AnthropicBeta(JsonField.of(value))
112123

113124
@JvmSynthetic
@@ -158,6 +169,9 @@ class AnthropicBeta @JsonCreator private constructor(private val value: JsonFiel
158169
TASK_BUDGETS_2026_03_13,
159170
THINKING_DISPLAY_UPDATES_2026_08_18,
160171
CE_USER_MANAGEMENT_2026_07_13,
172+
MID_CONVERSATION_OUTPUT_CONFIG_2026_07_01,
173+
THINKING_BINDING_CONTROLS_2026_08_01,
174+
MID_CONVERSATION_SYSTEM_CLEAR_AT_2026_08_21,
161175
}
162176

163177
/**
@@ -211,6 +225,9 @@ class AnthropicBeta @JsonCreator private constructor(private val value: JsonFiel
211225
TASK_BUDGETS_2026_03_13,
212226
THINKING_DISPLAY_UPDATES_2026_08_18,
213227
CE_USER_MANAGEMENT_2026_07_13,
228+
MID_CONVERSATION_OUTPUT_CONFIG_2026_07_01,
229+
THINKING_BINDING_CONTROLS_2026_08_01,
230+
MID_CONVERSATION_SYSTEM_CLEAR_AT_2026_08_21,
214231
/**
215232
* An enum member indicating that [AnthropicBeta] was instantiated with an unknown value.
216233
*/
@@ -269,6 +286,11 @@ class AnthropicBeta @JsonCreator private constructor(private val value: JsonFiel
269286
TASK_BUDGETS_2026_03_13 -> Value.TASK_BUDGETS_2026_03_13
270287
THINKING_DISPLAY_UPDATES_2026_08_18 -> Value.THINKING_DISPLAY_UPDATES_2026_08_18
271288
CE_USER_MANAGEMENT_2026_07_13 -> Value.CE_USER_MANAGEMENT_2026_07_13
289+
MID_CONVERSATION_OUTPUT_CONFIG_2026_07_01 ->
290+
Value.MID_CONVERSATION_OUTPUT_CONFIG_2026_07_01
291+
THINKING_BINDING_CONTROLS_2026_08_01 -> Value.THINKING_BINDING_CONTROLS_2026_08_01
292+
MID_CONVERSATION_SYSTEM_CLEAR_AT_2026_08_21 ->
293+
Value.MID_CONVERSATION_SYSTEM_CLEAR_AT_2026_08_21
272294
else -> Value._UNKNOWN
273295
}
274296

@@ -325,6 +347,11 @@ class AnthropicBeta @JsonCreator private constructor(private val value: JsonFiel
325347
TASK_BUDGETS_2026_03_13 -> Known.TASK_BUDGETS_2026_03_13
326348
THINKING_DISPLAY_UPDATES_2026_08_18 -> Known.THINKING_DISPLAY_UPDATES_2026_08_18
327349
CE_USER_MANAGEMENT_2026_07_13 -> Known.CE_USER_MANAGEMENT_2026_07_13
350+
MID_CONVERSATION_OUTPUT_CONFIG_2026_07_01 ->
351+
Known.MID_CONVERSATION_OUTPUT_CONFIG_2026_07_01
352+
THINKING_BINDING_CONTROLS_2026_08_01 -> Known.THINKING_BINDING_CONTROLS_2026_08_01
353+
MID_CONVERSATION_SYSTEM_CLEAR_AT_2026_08_21 ->
354+
Known.MID_CONVERSATION_SYSTEM_CLEAR_AT_2026_08_21
328355
else -> throw AnthropicInvalidDataException("Unknown AnthropicBeta: $value")
329356
}
330357

anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsModel.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ private constructor(private val value: JsonField<String>) : Enum {
2929

3030
companion object {
3131

32+
/**
33+
* Frontier intelligence for ambitious tasks across coding, scientific discovery, and
34+
* enterprise workflows
35+
*/
36+
@JvmField val CLAUDE_FABLE_5_1 = of("claude-fable-5-1")
37+
3238
/** High-performance model for coding and agents */
3339
@JvmField val CLAUDE_SONNET_5 = of("claude-sonnet-5")
3440

@@ -77,6 +83,11 @@ private constructor(private val value: JsonField<String>) : Enum {
7783

7884
/** An enum containing [BetaManagedAgentsModel]'s known values. */
7985
enum class Known {
86+
/**
87+
* Frontier intelligence for ambitious tasks across coding, scientific discovery, and
88+
* enterprise workflows
89+
*/
90+
CLAUDE_FABLE_5_1,
8091
/** High-performance model for coding and agents */
8192
CLAUDE_SONNET_5,
8293
/** Next generation of intelligence for the hardest knowledge work and coding problems */
@@ -115,6 +126,11 @@ private constructor(private val value: JsonField<String>) : Enum {
115126
* - It was constructed with an arbitrary value using the [of] method.
116127
*/
117128
enum class Value {
129+
/**
130+
* Frontier intelligence for ambitious tasks across coding, scientific discovery, and
131+
* enterprise workflows
132+
*/
133+
CLAUDE_FABLE_5_1,
118134
/** High-performance model for coding and agents */
119135
CLAUDE_SONNET_5,
120136
/** Next generation of intelligence for the hardest knowledge work and coding problems */
@@ -157,6 +173,7 @@ private constructor(private val value: JsonField<String>) : Enum {
157173
*/
158174
fun value(): Value =
159175
when (this) {
176+
CLAUDE_FABLE_5_1 -> Value.CLAUDE_FABLE_5_1
160177
CLAUDE_SONNET_5 -> Value.CLAUDE_SONNET_5
161178
CLAUDE_FABLE_5 -> Value.CLAUDE_FABLE_5
162179
CLAUDE_OPUS_5 -> Value.CLAUDE_OPUS_5
@@ -183,6 +200,7 @@ private constructor(private val value: JsonField<String>) : Enum {
183200
*/
184201
fun known(): Known =
185202
when (this) {
203+
CLAUDE_FABLE_5_1 -> Known.CLAUDE_FABLE_5_1
186204
CLAUDE_SONNET_5 -> Known.CLAUDE_SONNET_5
187205
CLAUDE_FABLE_5 -> Known.CLAUDE_FABLE_5
188206
CLAUDE_OPUS_5 -> Known.CLAUDE_OPUS_5

anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaFallbackParam.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,23 @@ private constructor(
555555
}
556556
)
557557

558+
fun blockBinding(): Optional<BetaThinkingBlockBinding> =
559+
accept(
560+
object : Visitor<Optional<BetaThinkingBlockBinding>> {
561+
override fun visitEnabled(
562+
enabled: BetaThinkingConfigEnabled
563+
): Optional<BetaThinkingBlockBinding> = enabled.blockBinding()
564+
565+
override fun visitDisabled(
566+
disabled: BetaThinkingConfigDisabled
567+
): Optional<BetaThinkingBlockBinding> = Optional.empty()
568+
569+
override fun visitAdaptive(
570+
adaptive: BetaThinkingConfigAdaptive
571+
): Optional<BetaThinkingBlockBinding> = adaptive.blockBinding()
572+
}
573+
)
574+
558575
fun enabled(): Optional<BetaThinkingConfigEnabled> = Optional.ofNullable(enabled)
559576

560577
fun disabled(): Optional<BetaThinkingConfigDisabled> = Optional.ofNullable(disabled)

0 commit comments

Comments
 (0)