Add Claude Fable 5 (`claude-fable-5`) and Claude Mythos 5 (`claude-mythos-5`) support

Merged
DS
6mo ago
+188-21

Adds support for the two Claude models introduced in anthropic SDK 0.108.0 — claude-fable-5 and claude-mythos-5 — and bumps the anthropic floor to the release that lists them.

claude-fable-5

Capabilities verified live against the Anthropic API, not assumed from a sibling — fable-5 mirrors the Claude Opus 4.8 profile (adaptive thinking, output_config.effort incl. xhigh, json-schema structured output + strict tools, task budgets, code execution 20260120, no sampling settings) with two subtractions:

  • No fast speed — anthropic_speed='fast' is rejected; fable-5 is simply omitted from the anthropic_supports_fast_speed prefix list.
  • No forced tool_choice — fable-5 rejects {'type':'any'}/{'type':'tool'} unconditionally (other Anthropic models only reject forcing alongside thinking). Modeled with a new AnthropicModelProfile.anthropic_supports_forced_tool_choice flag (default True): when False, a resolved required choice falls back to auto (filtering tool defs to the requested set), and an explicit forcing tool_choice ('required' or a list of tools) raises UserError. The flag is also set False for claude-mythos-preview, which the Anthropic docs document as 400-ing on forced tool use the same way.

anthropic>=0.108.0 and bridge removal

anthropic 0.108.0 is the first SDK release whose ModelParam lists claude-fable-5, so the floor is bumped to it (lock resolves to the latest, 0.109.0). With the SDK listing the model natively, the temporary AnthropicModelName = LatestAnthropicModelNames | Literal['claude-fable-5'] bridge is removed and AnthropicModelName goes back to the SDK's literal set — matching how Opus 4.8 (#5709) relied on the SDK rather than a hand-maintained literal.

The bump also reshapes the compaction-usage types: BetaUsage.iterations's discriminated union grows from 2 to 4 members and model becomes required on BetaMessageIterationUsage, so the _extract_usage_details unit tests construct that type with a model. Production code is unaffected (it filters iterations by type == 'compaction' and counts the rest).

claude-mythos-5

0.108.0 also adds claude-mythos-5, and test_known_model_names enforces that the SDK's Anthropic model list is a subset of KnownModelName, so the name is registered. Anthropic documents Mythos 5 as sharing Fable 5's capabilities "without the safety classifiers," so it gets the same profile as claude-fable-5 across every dimension (adaptive thinking, effort/xhigh, task budgets, json-schema output, code-exec 20260120, tool search, sampling/budget-thinking rejection, no fast speed, no forced tool_choice). The one flag the docs don't state for mythos-5 by name is forced-tool_choice rejection — inferred from it being both the documented successor to claude-mythos-preview and the safety-classifier-free twin of claude-fable-5, which both reject forcing.

Files

  • models/_known_model_names.py — anthropic: + gateway/anthropic: literals for both claude-fable-5 and claude-mythos-5.
  • models/anthropic.py — AnthropicModelName back to the SDK literal set (bridge removed); new anthropic_supports_forced_tool_choice threaded into _support_tool_forcing.
  • profiles/anthropic.py — fable-5 and mythos-5 added to the relevant capability prefix tuples; new anthropic_supports_forced_tool_choice flag set False for claude-fable-5, claude-mythos-5, and claude-mythos-preview.
  • pydantic_ai_slim/pyproject.toml + uv.lock — anthropic>=0.108.0.
  • tests/profiles/test_anthropic.py — test_model_profile_fable_5, test_model_profile_mythos_5, and the claude-mythos-preview forced-choice assertion.
  • tests/models/test_tool_choice_unit.py — forced-tool-choice fallback + explicit-forcing ('required' and list form) raise, parametrized over all no-forcing models.
  • tests/models/test_anthropic.py — compaction unit tests adapted to the 0.108.0 BetaMessageIterationUsage shape.
  • tests/test_capabilities.py — KnownModelName enum snapshot refreshed.

Notes

  • No new VCR cassette — the new behavior is request-prep logic, covered by unit tests; the shared capability flags (sampling drop, budget-thinking reject, xhigh) are already exercised by the Opus 4.7/4.8 parametrized tests, and the existing compaction cassettes validate under 0.109.0.
  • Docs deliberately untouched — this adds a new public profile flag and warrants a review round before documenting (per our PR flow; docs follow once behavior is confirmed).
  • Not added to Bedrock bedrock_structured_output_unsupported — neither model is in Bedrock's foundation-model list (direct-API models), so adding them there would be speculative.

Checklist

  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • No breaking changes in accordance with the version policy.
  • PR title is fit for the release changelog.