1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//! Reasoning effort — cross-vendor IR for "how hard should the model
//! reason before replying".
//!
//! The four 2026-Q2 reasoning-capable model families (Anthropic
//! extended-thinking, OpenAI o-series, Gemini 2.5/3 thinking,
//! Bedrock Converse Anthropic-passthrough) expose this knob in
//! incompatible wire shapes:
//!
//! - **Anthropic** — `thinking: { type: "enabled" | "adaptive" |
//! "disabled", budget_tokens: N }`. Opus 4.7 is adaptive-only —
//! manual `budget_tokens` is rejected. Sonnet 4.6 / 4.5 / Haiku
//! accept either `enabled` with explicit budget or `adaptive`.
//! - **OpenAI Responses** — `reasoning: { effort: "none" |
//! "minimal" | "low" | "medium" | "high" | "xhigh" }`. Discrete
//! bucket, no token budget.
//! - **Gemini 2.5** — `thinkingConfig: { thinkingBudget: N | -1 |
//! 0 }`. Token budget; `-1` is "auto", `0` disables (Flash only;
//! Pro cannot disable).
//! - **Gemini 3** — `thinkingConfig: { thinkingLevel: "minimal" |
//! "low" | "medium" | "high" }`. Discrete bucket only.
//! - **Bedrock Converse (Anthropic family)** — Anthropic passthrough
//! via `additionalModelRequestFields`. Same constraints as
//! Anthropic direct.
//!
//! [`ReasoningEffort`] is the cross-vendor enum every codec
//! translates onto its native wire shape. Translation is **lossy
//! by vendor design**, not by SDK design — the per-codec mapping
//! below documents exactly which variants fall through cleanly,
//! which approximate, and which emit `ModelWarning::LossyEncode`.
//!
//! ## Per-vendor mapping (encode-time)
//!
//! | `ReasoningEffort` | Anthropic | OpenAI Responses | Gemini 2.5 (Flash) | Gemini 2.5 (Pro) | Gemini 3 |
//! |-------------------|----------------------------------------------|-------------------------|---------------------------|---------------------------|---------------------------|
//! | `Off` | `{type:"disabled"}` | `effort:"none"` | `thinkingBudget:0` | LossyEncode → `512` | LossyEncode → `"minimal"` |
//! | `Minimal` | `{type:"adaptive", effort:"low"}` ¹ | `effort:"minimal"` | `thinkingBudget:512` ² | `thinkingBudget:512` | `thinkingLevel:"minimal"` |
//! | `Low` | `{type:"enabled", budget_tokens:1024}` | `effort:"low"` | `thinkingBudget:1024` | `thinkingBudget:1024` | `thinkingLevel:"low"` |
//! | `Medium` | `{type:"enabled", budget_tokens:4096}` | `effort:"medium"` | `thinkingBudget:8192` | `thinkingBudget:8192` | `thinkingLevel:"medium"` |
//! | `High` | `{type:"enabled", budget_tokens:16384}` | `effort:"high"` | `thinkingBudget:24576` | `thinkingBudget:24576` | `thinkingLevel:"high"` |
//! | `Auto` | `{type:"adaptive"}` (4.6+) | LossyEncode → `medium` | `thinkingBudget:-1` | `thinkingBudget:-1` | LossyEncode → `"high"` |
//! | `VendorSpecific` | passthrough — see [`Self::VendorSpecific`] | passthrough | passthrough | passthrough | passthrough |
//!
//! ¹ Anthropic Opus 4.7 emits `{type:"adaptive", effort:"low"}`
//! (manual budget is rejected). Sonnet 4.6 / 4.5 / Haiku emit
//! `{type:"adaptive", effort:"low"}` for parity with Opus 4.7.
//!
//! ² Gemini 2.5's `thinkingBudget` is a continuous integer; `512`
//! is the closest discrete approximation to "minimal" and emits
//! `LossyEncode` so operators see the snap.
//!
//! Every coercion site emits a typed
//! [`crate::ir::ModelWarning::LossyEncode`] so operators see the
//! information loss in observability — invariant 6.
use ;
/// How hard the model should reason before producing the
/// user-facing reply, abstracted across vendors.
///
/// The variants are deliberately ordinal-but-not-numeric:
/// `Minimal < Low < Medium < High` is meaningful, but they are
/// discrete buckets each codec snaps to its native shape, not
/// token counts. Operators that need the exact Anthropic
/// `budget_tokens` value or the exact Gemini `thinkingBudget`
/// integer reach for [`Self::VendorSpecific`].
///
/// The default is [`Self::Medium`] — matches every vendor's
/// "reasonable balance" tier.