From d86500efeaf904019f452529e970a5827b1b7964 Mon Sep 17 00:00:00 2001 From: polyhistor Date: Fri, 17 Jul 2026 20:13:50 +1200 Subject: [PATCH] fix(bedrock): add Claude Sonnet/Opus/Haiku 5 to Bedrock context-length table au.anthropic.claude-sonnet-5 (and opus-5/haiku-5) had no entry in BEDROCK_CONTEXT_LENGTHS, so get_bedrock_context_length() silently fell back to BEDROCK_DEFAULT_CONTEXT_LENGTH (128_000) instead of the actual 200_000 token window AWS documents for this model family on Bedrock. Impact: ContextCompressor's small-context floor treats any resolved window under 512K as 'small' and raises the compaction threshold to 75% of window. With the wrong 128K window that floor fires at 96,000 tokens instead of 150,000 tokens at the correct 200K window -- roughly 36% less usable headroom before Hermes force-compacts the conversation, causing more frequent/premature compaction on long agentic sessions. Verified locally: get_bedrock_context_length('au.anthropic.claude-sonnet-5') -> 200000 (was 128000 before this change) --- agent/bedrock_adapter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/agent/bedrock_adapter.py b/agent/bedrock_adapter.py index d5dab7bafff2e..fbd91ce594468 100644 --- a/agent/bedrock_adapter.py +++ b/agent/bedrock_adapter.py @@ -1297,6 +1297,9 @@ def classify_bedrock_error(error_message: str) -> str: BEDROCK_CONTEXT_LENGTHS: Dict[str, int] = { # Anthropic Claude models on Bedrock + "anthropic.claude-opus-5": 200_000, + "anthropic.claude-sonnet-5": 200_000, + "anthropic.claude-haiku-5": 200_000, "anthropic.claude-opus-4-6": 200_000, "anthropic.claude-sonnet-4-6": 200_000, "anthropic.claude-sonnet-4-5": 200_000,