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
55from .beta_container import BetaContainer
66from .beta_stop_reason import BetaStopReason
77from .beta_message_delta_usage import BetaMessageDeltaUsage
88from .beta_refusal_stop_details import BetaRefusalStopDetails
99from .beta_context_management_response import BetaContextManagementResponse
1010from .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
1516class 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+
3037class 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 """
0 commit comments