[plugins] Anthropic Python: thinking config modes + model-aware validation
Parent: #5617 (Phase A, P0: item 11)
Why
The request path only understands enabled + budget_tokens; disabled, adaptive, and display are silently ignored. Worse, the manual-budget_tokens shape is exactly the form that newer 4.6/4.7/4.8 models reject under the current API, so thinking may be effectively non-functional across much of the shipped registry, surfacing as raw API 400s rather than anything actionable.
Matching the JS thinking modes makes the feature usable and predictable across the current model lineup, and turns a raw API 400 into a clear, local error.
Verify first (blocks design)
Before coding, confirm against the live Anthropic API whether 4.6/4.7/4.8 actually reject the manual budget_tokens shape, and what they accept instead (adaptive, or enabled with no manual budget). The whole request-shape decision — send budget_tokens vs force adaptive on newer models — hangs on this. Mirror the Go anthropic_live_test.go approach. Do not build the validation table on the assumption alone.
What needs to be done
- Support the full set of thinking modes (
enabledwith budget,disabled, andadaptivewithdisplay), mapped to the correct Anthropic request shape, mirroring the JS thinking schema. - Validate combinations in a model-aware way (e.g. newer models that reject manual budgets or
disabledthinking) so callers get a clear error instead of a raw 400. Keepenabledandadaptivemutually exclusive, and require a budget whenenabled. - Enforce the
max_tokens > thinking.budget_tokensAPI constraint. The defaultmax_tokensis 4096 (models.py:61,202); a caller-supplied budget at or above it produces a raw 400. Whenenabledwith a budget, auto-raisemax_tokensto clear the budget (or validate and error locally), so thinking does not silently 400.
Dependencies
- Typed config schema (item 33, #5627 ) for the typed modes.
- Thinking response side (items 12-14, #5628 ) so the signature round-trip is testable.
Acceptance
- All thinking modes are honored and sent in the correct shape.
- Invalid or unsupported combinations are caught locally with a clear error rather than a raw API failure.
- Tests cover each mode and the validation paths.
Reference
- Current handling:
py/plugins/anthropic/src/genkit/plugins/anthropic/models.py:217-229. - JS target:
js/plugins/anthropic/src/types.ts:68-101(ThinkingConfigSchema).