|
5 | 5 | namespace Anthropic\Beta\Messages; |
6 | 6 |
|
7 | 7 | use Anthropic\Beta\Messages\BetaRawMessageDeltaEvent\Delta; |
| 8 | +use Anthropic\Core\Attributes\Optional; |
8 | 9 | use Anthropic\Core\Attributes\Required; |
9 | 10 | use Anthropic\Core\Concerns\SdkModel; |
10 | 11 | use Anthropic\Core\Contracts\BaseModel; |
|
13 | 14 | * @phpstan-import-type BetaContextManagementResponseShape from \Anthropic\Beta\Messages\BetaContextManagementResponse |
14 | 15 | * @phpstan-import-type DeltaShape from \Anthropic\Beta\Messages\BetaRawMessageDeltaEvent\Delta |
15 | 16 | * @phpstan-import-type BetaMessageDeltaUsageShape from \Anthropic\Beta\Messages\BetaMessageDeltaUsage |
| 17 | + * @phpstan-import-type BetaThinkingDroppedInputTransformationShape from \Anthropic\Beta\Messages\BetaThinkingDroppedInputTransformation |
16 | 18 | * |
17 | 19 | * @phpstan-type BetaRawMessageDeltaEventShape = array{ |
18 | 20 | * contextManagement: null|BetaContextManagementResponse|BetaContextManagementResponseShape, |
19 | 21 | * delta: Delta|DeltaShape, |
20 | 22 | * type: 'message_delta', |
21 | 23 | * usage: BetaMessageDeltaUsage|BetaMessageDeltaUsageShape, |
| 24 | + * inputTransformations?: list<BetaThinkingDroppedInputTransformation|BetaThinkingDroppedInputTransformationShape>|null, |
22 | 25 | * } |
23 | 26 | */ |
24 | 27 | final class BetaRawMessageDeltaEvent implements BaseModel |
@@ -53,6 +56,32 @@ final class BetaRawMessageDeltaEvent implements BaseModel |
53 | 56 | #[Required] |
54 | 57 | public BetaMessageDeltaUsage $usage; |
55 | 58 |
|
| 59 | + /** |
| 60 | + * Changes the API made to the request's input before showing it to the model: |
| 61 | + * one entry per change, in request order. Today the only entry type is |
| 62 | + * `thinking_dropped` — a `thinking`, `redacted_thinking` or `connector_text` |
| 63 | + * block from the request's `messages` that was removed from the prompt instead |
| 64 | + * of being shown to the model because it failed a binding check. More entry |
| 65 | + * types may be added over time; ignore types you do not recognize. |
| 66 | + * |
| 67 | + * Requires `anthropic-beta: thinking-binding-controls-2026-08-01`. Present on |
| 68 | + * every such response from a model that supports extended thinking, as `[]` |
| 69 | + * when nothing was changed; without the beta, blocks are removed all the same |
| 70 | + * but nothing is reported. Removed blocks contribute nothing to |
| 71 | + * `usage.input_tokens`. When streaming, the array is final in `message_start`; |
| 72 | + * the final `message_delta` event carries it only when a server-side model |
| 73 | + * fallback happened mid-stream, in which case it holds the serving model's |
| 74 | + * entries and replaces the one in `message_start`. |
| 75 | + * |
| 76 | + * @var list<BetaThinkingDroppedInputTransformation>|null $inputTransformations |
| 77 | + */ |
| 78 | + #[Optional( |
| 79 | + 'input_transformations', |
| 80 | + list: BetaThinkingDroppedInputTransformation::class, |
| 81 | + nullable: true, |
| 82 | + )] |
| 83 | + public ?array $inputTransformations; |
| 84 | + |
56 | 85 | /** |
57 | 86 | * `new BetaRawMessageDeltaEvent()` is missing required properties by the API. |
58 | 87 | * |
@@ -83,18 +112,22 @@ public function __construct() |
83 | 112 | * @param BetaContextManagementResponse|BetaContextManagementResponseShape|null $contextManagement |
84 | 113 | * @param Delta|DeltaShape $delta |
85 | 114 | * @param BetaMessageDeltaUsage|BetaMessageDeltaUsageShape $usage |
| 115 | + * @param list<BetaThinkingDroppedInputTransformation|BetaThinkingDroppedInputTransformationShape>|null $inputTransformations |
86 | 116 | */ |
87 | 117 | public static function with( |
88 | 118 | BetaContextManagementResponse|array|null $contextManagement, |
89 | 119 | Delta|array $delta, |
90 | 120 | BetaMessageDeltaUsage|array $usage, |
| 121 | + ?array $inputTransformations = null, |
91 | 122 | ): self { |
92 | 123 | $self = new self; |
93 | 124 |
|
94 | 125 | $self['contextManagement'] = $contextManagement; |
95 | 126 | $self['delta'] = $delta; |
96 | 127 | $self['usage'] = $usage; |
97 | 128 |
|
| 129 | + null !== $inputTransformations && $self['inputTransformations'] = $inputTransformations; |
| 130 | + |
98 | 131 | return $self; |
99 | 132 | } |
100 | 133 |
|
@@ -154,4 +187,31 @@ public function withUsage(BetaMessageDeltaUsage|array $usage): self |
154 | 187 |
|
155 | 188 | return $self; |
156 | 189 | } |
| 190 | + |
| 191 | + /** |
| 192 | + * Changes the API made to the request's input before showing it to the model: |
| 193 | + * one entry per change, in request order. Today the only entry type is |
| 194 | + * `thinking_dropped` — a `thinking`, `redacted_thinking` or `connector_text` |
| 195 | + * block from the request's `messages` that was removed from the prompt instead |
| 196 | + * of being shown to the model because it failed a binding check. More entry |
| 197 | + * types may be added over time; ignore types you do not recognize. |
| 198 | + * |
| 199 | + * Requires `anthropic-beta: thinking-binding-controls-2026-08-01`. Present on |
| 200 | + * every such response from a model that supports extended thinking, as `[]` |
| 201 | + * when nothing was changed; without the beta, blocks are removed all the same |
| 202 | + * but nothing is reported. Removed blocks contribute nothing to |
| 203 | + * `usage.input_tokens`. When streaming, the array is final in `message_start`; |
| 204 | + * the final `message_delta` event carries it only when a server-side model |
| 205 | + * fallback happened mid-stream, in which case it holds the serving model's |
| 206 | + * entries and replaces the one in `message_start`. |
| 207 | + * |
| 208 | + * @param list<BetaThinkingDroppedInputTransformation|BetaThinkingDroppedInputTransformationShape>|null $inputTransformations |
| 209 | + */ |
| 210 | + public function withInputTransformations(?array $inputTransformations): self |
| 211 | + { |
| 212 | + $self = clone $this; |
| 213 | + $self['inputTransformations'] = $inputTransformations; |
| 214 | + |
| 215 | + return $self; |
| 216 | + } |
157 | 217 | } |
0 commit comments