Commit ee15098
authored
Support Claude Opus 4.7+ adaptive thinking (#119)
Anthropic rejects manual extended thinking on Claude Opus 4.7 and 4.8
with HTTP 400. These models require adaptive thinking, where depth is
controlled via a top-level `output_config.effort` parameter rather
than the legacy `thinking.budget_tokens` field.
The previous auto-detection had only a single thinking mode (manual)
and matched any `claude-opus-4*` ID, so any request to Opus 4.7+
failed before reaching the model.
Replace the boolean `supports_thinking` switch with a `ThinkingMode`
enum that distinguishes three cases:
- Adaptive: emits `thinking: {type: "adaptive"}` together with
`output_config: {effort: "high"}`. Selected for `claude-opus-4-7`,
`claude-opus-4-8`, and the `claude-opus-latest` alias.
- Manual: keeps the existing `{type: "enabled", budget_tokens: N}`
payload. Selected for Sonnet 4.x, Claude 3.7 Sonnet, and Opus 4
through 4.6.
- None: unchanged for non-thinking models.
Users can still override the default effort level (or any other
field) per model via the `config` block in `models.json`, which is
shallow-merged into the request.
Add a unit test covering all three branches of the new detection,
extend `models.example.json` with an Opus 4.7 entry, and document
the new shape and override mechanism in the README with links to
Anthropic's extended-thinking and effort documentation.1 parent 98ebeba commit ee15098
3 files changed
Lines changed: 162 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
187 | 200 | | |
188 | 201 | | |
189 | 202 | | |
| |||
212 | 225 | | |
213 | 226 | | |
214 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
215 | 238 | | |
216 | 239 | | |
217 | 240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
568 | 584 | | |
569 | | - | |
570 | | - | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
571 | 602 | | |
572 | 603 | | |
573 | 604 | | |
574 | | - | |
575 | | - | |
576 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
577 | 614 | | |
578 | 615 | | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
579 | 625 | | |
580 | 626 | | |
581 | 627 | | |
| |||
1311 | 1357 | | |
1312 | 1358 | | |
1313 | 1359 | | |
1314 | | - | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
1322 | 1363 | | |
1323 | | - | |
| 1364 | + | |
1324 | 1365 | | |
1325 | 1366 | | |
1326 | 1367 | | |
| |||
1330 | 1371 | | |
1331 | 1372 | | |
1332 | 1373 | | |
1333 | | - | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
1334 | 1377 | | |
1335 | 1378 | | |
1336 | | - | |
1337 | | - | |
1338 | 1379 | | |
1339 | 1380 | | |
1340 | 1381 | | |
1341 | 1382 | | |
1342 | 1383 | | |
1343 | 1384 | | |
1344 | | - | |
1345 | | - | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
1346 | 1400 | | |
| 1401 | + | |
1347 | 1402 | | |
1348 | 1403 | | |
1349 | 1404 | | |
| |||
1938 | 1993 | | |
1939 | 1994 | | |
1940 | 1995 | | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
1941 | 2046 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
2 | 17 | | |
3 | 18 | | |
4 | 19 | | |
| |||
0 commit comments