Skip to content

fix: retire context-1m-2025-08-07 beta header for Sonnet 4.0 and 4.5 - #51

Open
Ken Chau (kenotron-ms) wants to merge 2 commits into
mainfrom
fix/retire-1m-beta-header
Open

fix: retire context-1m-2025-08-07 beta header for Sonnet 4.0 and 4.5#51
Ken Chau (kenotron-ms) wants to merge 2 commits into
mainfrom
fix/retire-1m-beta-header

Conversation

@kenotron-ms

Copy link
Copy Markdown
Contributor

Summary

Closes / related to: microsoft-amplifier/amplifier-shared#42

Anthropic retired the context-1m-2025-08-07 beta header for Sonnet 4.0 (claude-sonnet-4-20250514) and Sonnet 4.5 on 2026-04-30. The header now has no effect on those models; any context exceeding the 200k standard limit returns a 400 INVALID_ARGUMENT. Previously, the provider was sending this retired header for all Sonnet ≥ 4.0.

Changes

amplifier_module_provider_anthropic/__init__.py

  • _should_add_context_1m_beta: Scoped the Sonnet branch from >= (4, 0)>= (4, 6). Header now only sent for Sonnet 4.6+ (where 1M is GA) and unknown versions (forward-compat). Opus gate was already correctly at 4.6+.
  • _DEPRECATED_MODELS: Removed claude-3-haiku-20240307 (retirement date 2026-04-19 is past; the model is fully retired).
  • _should_add_interleaved_beta: Added clarifying comment confirming Opus 4.6+ adaptive thinking already prevents the interleaved-thinking-2025-05-14 header from being sent (no logic change needed).

Tests (test_opus_47.py, test_fallback.py)

  • Renamed test_sonnet_45_gets_1m_headertest_sonnet_45_no_1m_header and flipped assertion to False
  • Added test_sonnet_40_no_1m_header for claude-sonnet-4-20250514
  • Updated deprecated-models tests to use claude-sonnet-4-20250514 (Haiku 3 removed from dict)
  • Renamed test_sonnet_45_still_adds_context_beta_header_when_enabledtest_sonnet_45_no_longer_gets_context_beta_header

Test evidence

  • 410 tests pass (full suite)
  • DTU validated (instance issue-42-validation):
    • _should_add_context_1m_beta("claude-sonnet-4-5-20250929", ...)False
    • _should_add_context_1m_beta("claude-sonnet-4-20250514", ...)False
    • _should_add_context_1m_beta("claude-sonnet-4-6-...", ...)True
    • _DEPRECATED_MODELS no longer contains claude-3-haiku-20240307
    • Full pytest suite: 410 passed ✅

Check-in note

No dependent repo changes required. amplifier-bundle-routing-matrix should be reviewed separately to update any routing that sends long-context workloads to Sonnet 4.5 (tracked in microsoft-amplifier/amplifier-shared#42).

Ken Chau (kenotron-ms) and others added 2 commits May 5, 2026 10:43
Retiring the `context-1m-2025-08-07` beta header for Sonnet 4.0 and 4.5:
- Header was deprecated by Anthropic on 2026-04-30
- Those models now hard-cap at 200k context regardless
- Updated `_should_add_context_1m_beta` to only send header for Sonnet 4.6+
  and unknown versions (forward-compat)
- Removed `claude-3-haiku-20240307` from `_DEPRECATED_MODELS` dict
  (retired 2026-04-19, no longer needs a warning)
- Added clarifying comment confirming interleaved-thinking guard correctly
  prevents deprecated header on Opus 4.6+ adaptive
- Updated 6 tests in test_opus_47.py and test_fallback.py to reflect new
  behavior
- All 410 tests pass

Fixes #42

Generated with Amplifier

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
- Added enable_1m_context startup check in __init__ that fires for Sonnet/Opus <4.6
  whose 1M beta was retired 2026-04-30. Warns user sessions are capped at 200k and
  suggests migration to 4.6+
- Moved Haiku 3 tombstone comment out of dict literal body to standalone comment
  above _DEPRECATED_MODELS for clarity
- Added 8 new tests in TestEnable1mContextRetirementWarning covering:
  - warning fires for Sonnet 4.5 and Opus 4.5
  - no warning for Sonnet/Opus 4.6+
  - warning suppressed when enable_1m_context=False
  - no false positives for unknown versions

Fixes microsoft-amplifier/amplifier-shared#42

Generated with Amplifier

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant