fix(bedrock): raise Claude 4.x context window to 1M and add opus-4-7

Claude 4.x models on Bedrock support a 1M-token context window via the
context-1m-2025-08-07 beta header, which Hermes already injects
automatically in build_anthropic_bedrock_client
(agent/anthropic_adapter.py). However, BEDROCK_CONTEXT_LENGTHS in
agent/bedrock_adapter.py still reported 200K for opus-4-6, sonnet-4-6,
sonnet-4-5, and haiku-4-5, and had no entry at all for opus-4-7 (which
falls back via substring match to the 200K opus-4 entry).

This caused Hermes to display a 200K window, compress conversations
earlier than necessary (compression.threshold * 200K instead of * 1M),
and generally under-utilize the full 1M context users are paying for.

The fix is metadata-only — the Bedrock API and beta header already
support 1M end-to-end. agent/model_metadata.py's DEFAULT_CONTEXT_LENGTHS
table already lists claude-opus-4-7 / -4-6 / sonnet-4-6 at 1M for the
non-Bedrock paths, so this change brings the Bedrock table into
alignment.

Changes:
- Add anthropic.claude-opus-4-7 at 1_000_000
- Bump anthropic.claude-opus-4-6 from 200_000 to 1_000_000
- Bump anthropic.claude-sonnet-4-6 from 200_000 to 1_000_000
- Bump anthropic.claude-sonnet-4-5 from 200_000 to 1_000_000
- Bump anthropic.claude-haiku-4-5 from 200_000 to 1_000_000
- Add explanatory comment pointing readers at the beta-header injection
  site in agent/anthropic_adapter.py
This commit is contained in:
Patrick Muller 2026-05-11 16:55:26 -07:00 committed by Teknium
parent 47fb20c0bd
commit c02466d5e8

View file

@ -1321,12 +1321,16 @@ def classify_bedrock_error(error_message: str) -> str:
# detection is unavailable.
BEDROCK_CONTEXT_LENGTHS: Dict[str, int] = {
# Anthropic Claude models on Bedrock
# Anthropic Claude models on Bedrock.
# Claude 4.x (opus/sonnet/haiku) support a 1M-token context window via the
# ``context-1m-2025-08-07`` beta header, which Hermes injects automatically
# in ``build_anthropic_bedrock_client`` (see agent/anthropic_adapter.py).
"anthropic.claude-sonnet-5": 1_000_000,
"anthropic.claude-opus-4-6": 200_000,
"anthropic.claude-sonnet-4-6": 200_000,
"anthropic.claude-sonnet-4-5": 200_000,
"anthropic.claude-haiku-4-5": 200_000,
"anthropic.claude-opus-4-7": 1_000_000,
"anthropic.claude-opus-4-6": 1_000_000,
"anthropic.claude-sonnet-4-6": 1_000_000,
"anthropic.claude-sonnet-4-5": 1_000_000,
"anthropic.claude-haiku-4-5": 1_000_000,
"anthropic.claude-opus-4": 200_000,
"anthropic.claude-sonnet-4": 200_000,
"anthropic.claude-3-5-sonnet": 200_000,