diff --git a/tests/test_anthropic_effort.py b/tests/test_anthropic_effort.py index d576f6aa6..7677eb936 100644 --- a/tests/test_anthropic_effort.py +++ b/tests/test_anthropic_effort.py @@ -28,6 +28,8 @@ class TestEffortGate: "claude-haiku-4-5", "claude-haiku-5-0", "claude-haiku-4-7-preview", # Sonnet 4.5 (and earlier) 400 on effort — only Sonnet 4.6+ supports it. "claude-sonnet-4-5", "claude-sonnet-4-0", + # A dated snapshot's date is not its minor version (#1585). + "claude-sonnet-4-20250514", "claude-opus-4-20250514", "claude-sonnet-4-5-20250929", ], ) def test_unsupported_models_do_not_receive_effort(self, monkeypatch, model): @@ -39,7 +41,7 @@ class TestEffortGate: "model", [ "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", - "claude-sonnet-4-6", + "claude-sonnet-4-6", "claude-opus-4-5-20251101", ], ) def test_current_opus_and_sonnet_receive_effort(self, monkeypatch, model): diff --git a/tradingagents/llm_clients/anthropic_client.py b/tradingagents/llm_clients/anthropic_client.py index 23772c65c..ab0a21c7c 100644 --- a/tradingagents/llm_clients/anthropic_client.py +++ b/tradingagents/llm_clients/anthropic_client.py @@ -15,12 +15,13 @@ _PASSTHROUGH_KWARGS = ( # Sonnet 4.6+, and the Claude 5 family (Sonnet 5, Opus 5.5, Fable 5). Sonnet 4.5 and any # Haiku version 400 with ``"This model does not support the effort parameter"`` # (#831). Versions may be dotted (``opus-4-8``) or single-number (``sonnet-5``, -# ``fable-5``); the per-family minimum below is forward-compatible. +# ``fable-5``), and a snapshot carries its date (``sonnet-4-20250514``), which is +# not a minor version; the per-family minimum below is forward-compatible. _EFFORT_EXACT = { "claude-mythos-preview", # non-standard preview name; effort-capable "claude-mythos-5", # Fable 5 twin (Project Glasswing); effort-capable } -_EFFORT_MODEL = re.compile(r"^claude-(opus|sonnet|fable)-(\d+)(?:-(\d+))?$") +_EFFORT_MODEL = re.compile(r"^claude-(opus|sonnet|fable)-(\d+)(?:-(\d{1,2}))?(?:-\d{8})?$") _EFFORT_MIN_VERSION = {"opus": (4, 5), "sonnet": (4, 6), "fable": (5, 0)}