Skip to content

Commit 14d1792

Browse files
feat(api): add thinking_mismatch_allowed entries to input_transformations (beta)
Stainless-Generated-From: fd851ba1d88ae230e58ff413cca443158a8a9b56
1 parent bb06629 commit 14d1792

7 files changed

Lines changed: 102 additions & 31 deletions

File tree

‎api.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ from anthropic.types.beta import (
572572
BetaInputJSONDelta,
573573
BetaInputTokensClearAtLeast,
574574
BetaInputTokensTrigger,
575+
BetaInputTransformation,
575576
BetaIterationsUsage,
576577
BetaJSONOutputFormat,
577578
BetaMCPToolConfig,
@@ -648,6 +649,7 @@ from anthropic.types.beta import (
648649
BetaThinkingConfigParam,
649650
BetaThinkingDelta,
650651
BetaThinkingDroppedInputTransformation,
652+
BetaThinkingMismatchAllowedInputTransformation,
651653
BetaThinkingPrefixMismatchBehavior,
652654
BetaThinkingTurns,
653655
BetaTokenTaskBudget,

‎scripts/mock-spec.json.gz‎

455 Bytes
Binary file not shown.

‎src/anthropic/types/beta/__init__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
from .beta_advisor_result_block import BetaAdvisorResultBlock as BetaAdvisorResultBlock
116116
from .beta_dream_sessions_input import BetaDreamSessionsInput as BetaDreamSessionsInput
117117
from .beta_fallback_block_param import BetaFallbackBlockParam as BetaFallbackBlockParam
118+
from .beta_input_transformation import BetaInputTransformation as BetaInputTransformation
118119
from .beta_managed_agents_agent import BetaManagedAgentsAgent as BetaManagedAgentsAgent
119120
from .beta_managed_agents_model import BetaManagedAgentsModel as BetaManagedAgentsModel
120121
from .beta_managed_agents_vault import BetaManagedAgentsVault as BetaManagedAgentsVault
@@ -978,6 +979,9 @@
978979
from .beta_text_editor_code_execution_create_result_block import (
979980
BetaTextEditorCodeExecutionCreateResultBlock as BetaTextEditorCodeExecutionCreateResultBlock,
980981
)
982+
from .beta_thinking_mismatch_allowed_input_transformation import (
983+
BetaThinkingMismatchAllowedInputTransformation as BetaThinkingMismatchAllowedInputTransformation,
984+
)
981985
from .beta_managed_agents_agent_toolset20260401_bash_input import (
982986
BetaManagedAgentsAgentToolset20260401BashInput as BetaManagedAgentsAgentToolset20260401BashInput,
983987
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import Union
2+
from typing_extensions import Annotated, TypeAlias
3+
4+
from ..._models import UnionDiscriminator
5+
from .beta_thinking_dropped_input_transformation import BetaThinkingDroppedInputTransformation
6+
from .beta_thinking_mismatch_allowed_input_transformation import BetaThinkingMismatchAllowedInputTransformation
7+
8+
__all__ = ["BetaInputTransformation"]
9+
10+
BetaInputTransformation: TypeAlias = Annotated[
11+
Union[BetaThinkingDroppedInputTransformation, BetaThinkingMismatchAllowedInputTransformation],
12+
UnionDiscriminator("type"),
13+
]

‎src/anthropic/types/beta/beta_message.py‎

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
from .beta_diagnostics import BetaDiagnostics
99
from .beta_stop_reason import BetaStopReason
1010
from .beta_content_block import BetaContentBlock, BetaContentBlock as BetaContentBlock
11+
from .beta_input_transformation import BetaInputTransformation
1112
from .beta_message_param import BetaMessageParam
1213
from .beta_refusal_stop_details import BetaRefusalStopDetails
1314
from .beta_context_management_response import BetaContextManagementResponse
14-
from .beta_thinking_dropped_input_transformation import BetaThinkingDroppedInputTransformation
1515

1616
__all__ = ["BetaMessage"]
1717

@@ -143,23 +143,28 @@ class BetaMessage(BaseModel):
143143
`cache_creation_input_tokens`, and `cache_read_input_tokens`.
144144
"""
145145

146-
input_transformations: Optional[List[BetaThinkingDroppedInputTransformation]] = None
146+
input_transformations: Optional[List[BetaInputTransformation]] = None
147147
"""
148-
Changes the API made to the request's input before showing it to the model: one
149-
entry per change, in request order. Today the only entry type is
150-
`thinking_dropped` — a `thinking`, `redacted_thinking` or `connector_text` block
151-
from the request's `messages` that was removed from the prompt instead of being
152-
shown to the model because it failed a binding check. More entry types may be
153-
added over time; ignore types you do not recognize.
148+
Changes the API made to the request's input before showing it to the model, and
149+
blocks that failed a binding check but were left unchanged: one entry per block,
150+
in request order. Two entry types today. `thinking_dropped` — a `thinking`,
151+
`redacted_thinking` or `connector_text` block from the request's `messages` that
152+
was removed from the prompt instead of being shown to the model because it
153+
failed a binding check. `thinking_mismatch_allowed` — a `thinking` or
154+
`redacted_thinking` block that failed the conversation check (the conversation
155+
before it differs from the one it was created in, or it carries no record of one
156+
on a model that requires it) and was shown to the model all the same, because
157+
that check is not enforced for this request. More entry types may be added over
158+
time; ignore types you do not recognize.
154159
155160
Requires `anthropic-beta: thinking-binding-controls-2026-08-01`. Present on
156161
every such response from a model that supports extended thinking, as `[]` when
157-
nothing was changed; without the beta, blocks are removed all the same but
158-
nothing is reported. Removed blocks contribute nothing to `usage.input_tokens`.
159-
When streaming, the array is final in `message_start`; the final `message_delta`
160-
event carries it only when a server-side model fallback happened mid-stream, in
161-
which case it holds the serving model's entries and replaces the one in
162-
`message_start`.
162+
there is no entry to report; without the beta, blocks are removed or left in
163+
place all the same but nothing is reported. Removed blocks contribute nothing to
164+
`usage.input_tokens`; blocks left in place count as sent. When streaming, the
165+
array is final in `message_start`; the final `message_delta` event carries it
166+
only when a server-side model fallback happened mid-stream, in which case it
167+
holds the serving model's entries and replaces the one in `message_start`.
163168
"""
164169

165170
def to_param(self) -> BetaMessageParam:

‎src/anthropic/types/beta/beta_raw_message_delta_event.py‎

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
from typing import List, Optional
2-
from typing_extensions import Literal
1+
from typing import List, Union, Optional
2+
from typing_extensions import Literal, Annotated, TypeAlias
33

4-
from ..._models import BaseModel
4+
from ..._models import BaseModel, UnionDiscriminator
55
from .beta_container import BetaContainer
66
from .beta_stop_reason import BetaStopReason
77
from .beta_message_delta_usage import BetaMessageDeltaUsage
88
from .beta_refusal_stop_details import BetaRefusalStopDetails
99
from .beta_context_management_response import BetaContextManagementResponse
1010
from .beta_thinking_dropped_input_transformation import BetaThinkingDroppedInputTransformation
11+
from .beta_thinking_mismatch_allowed_input_transformation import BetaThinkingMismatchAllowedInputTransformation
1112

12-
__all__ = ["BetaRawMessageDeltaEvent", "Delta"]
13+
__all__ = ["BetaRawMessageDeltaEvent", "Delta", "InputTransformation"]
1314

1415

1516
class Delta(BaseModel):
@@ -27,6 +28,12 @@ class Delta(BaseModel):
2728
stop_sequence: Optional[str] = None
2829

2930

31+
InputTransformation: TypeAlias = Annotated[
32+
Union[BetaThinkingDroppedInputTransformation, BetaThinkingMismatchAllowedInputTransformation],
33+
UnionDiscriminator("type"),
34+
]
35+
36+
3037
class BetaRawMessageDeltaEvent(BaseModel):
3138
context_management: Optional[BetaContextManagementResponse] = None
3239
"""Information about context management strategies applied during the request"""
@@ -53,21 +60,26 @@ class BetaRawMessageDeltaEvent(BaseModel):
5360
`cache_creation_input_tokens`, and `cache_read_input_tokens`.
5461
"""
5562

56-
input_transformations: Optional[List[BetaThinkingDroppedInputTransformation]] = None
63+
input_transformations: Optional[List[InputTransformation]] = None
5764
"""
58-
Changes the API made to the request's input before showing it to the model: one
59-
entry per change, in request order. Today the only entry type is
60-
`thinking_dropped` — a `thinking`, `redacted_thinking` or `connector_text` block
61-
from the request's `messages` that was removed from the prompt instead of being
62-
shown to the model because it failed a binding check. More entry types may be
63-
added over time; ignore types you do not recognize.
65+
Changes the API made to the request's input before showing it to the model, and
66+
blocks that failed a binding check but were left unchanged: one entry per block,
67+
in request order. Two entry types today. `thinking_dropped` — a `thinking`,
68+
`redacted_thinking` or `connector_text` block from the request's `messages` that
69+
was removed from the prompt instead of being shown to the model because it
70+
failed a binding check. `thinking_mismatch_allowed` — a `thinking` or
71+
`redacted_thinking` block that failed the conversation check (the conversation
72+
before it differs from the one it was created in, or it carries no record of one
73+
on a model that requires it) and was shown to the model all the same, because
74+
that check is not enforced for this request. More entry types may be added over
75+
time; ignore types you do not recognize.
6476
6577
Requires `anthropic-beta: thinking-binding-controls-2026-08-01`. Present on
6678
every such response from a model that supports extended thinking, as `[]` when
67-
nothing was changed; without the beta, blocks are removed all the same but
68-
nothing is reported. Removed blocks contribute nothing to `usage.input_tokens`.
69-
When streaming, the array is final in `message_start`; the final `message_delta`
70-
event carries it only when a server-side model fallback happened mid-stream, in
71-
which case it holds the serving model's entries and replaces the one in
72-
`message_start`.
79+
there is no entry to report; without the beta, blocks are removed or left in
80+
place all the same but nothing is reported. Removed blocks contribute nothing to
81+
`usage.input_tokens`; blocks left in place count as sent. When streaming, the
82+
array is final in `message_start`; the final `message_delta` event carries it
83+
only when a server-side model fallback happened mid-stream, in which case it
84+
holds the serving model's entries and replaces the one in `message_start`.
7385
"""
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from typing_extensions import Literal
2+
3+
from ..._models import BaseModel
4+
5+
__all__ = ["BetaThinkingMismatchAllowedInputTransformation"]
6+
7+
8+
class BetaThinkingMismatchAllowedInputTransformation(BaseModel):
9+
path: str
10+
"""
11+
Where the block is in your request, as `messages.{i}.content.{j}`: `i` indexes
12+
the `messages` array you sent and `j` that message's `content` array — the same
13+
form error messages use.
14+
"""
15+
16+
reason: Literal[
17+
"model_binding_mismatch",
18+
"prefix_binding_mismatch",
19+
"organization_binding_mismatch",
20+
"end_user_binding_mismatch",
21+
]
22+
"""
23+
Which binding check the block failed; the block was shown to the model all the
24+
same. Always `prefix_binding_mismatch` today — the conversation before the block
25+
differs from the conversation it was created in, or the block carries no record
26+
of one on a model that requires it. Were the check enforced for this request,
27+
the block would have been removed or the request rejected
28+
(`thinking.block_binding.prefix_mismatch_behavior`). A removal also takes the
29+
rest of that turn's consecutive thinking blocks, whereas here each block is
30+
checked on its own, so `thinking_mismatch_allowed` entries are a lower bound on
31+
what enforcement would remove.
32+
"""
33+
34+
type: Literal["thinking_mismatch_allowed"]
35+
"""Always `thinking_mismatch_allowed` for this entry type."""

0 commit comments

Comments
 (0)