fix: reconcile probe cache with stale-entry invalidation + stale test fixtures
- The #44861 stale-cache guard invalidated any cached value that differed from the static table, which would have discarded legitimate probe-derived windows larger than the table. Treat the table as a FLOOR: only drop under-reporting cache entries. - Update probe test fixtures that predated the 4.6+ 1M table flip (opus-4-6 fallback expectations 200K -> 1M).
This commit is contained in:
parent
6be4944bc0
commit
58391436f7
|
|
@ -2250,12 +2250,16 @@ def get_model_context_length(
|
|||
)
|
||||
# Fall through; step 5b reconciles and overwrites if portal responds.
|
||||
# Invalidate stale Bedrock entries seeded before the Claude 4.6+
|
||||
# long-context table was corrected to 1M.
|
||||
# long-context table was corrected to 1M. The static table is a
|
||||
# FLOOR, not an override: probe-derived cache entries (step 1b)
|
||||
# may legitimately exceed the table (real window read from
|
||||
# Bedrock's length-validation error), so only under-reporting
|
||||
# entries are dropped — never a cached value above the table.
|
||||
elif is_bedrock_context:
|
||||
try:
|
||||
from agent.bedrock_adapter import get_bedrock_context_length
|
||||
bedrock_ctx = get_bedrock_context_length(model)
|
||||
if cached != bedrock_ctx:
|
||||
if cached < bedrock_ctx:
|
||||
logger.info(
|
||||
"Dropping stale Bedrock cache entry %s@%s -> %s; "
|
||||
"using static Bedrock table value %s",
|
||||
|
|
|
|||
|
|
@ -1244,7 +1244,7 @@ class TestBedrockContextLength:
|
|||
# still invoke get_bedrock_context_length(model_id) with one arg.
|
||||
from agent.bedrock_adapter import get_bedrock_context_length
|
||||
with patch("agent.bedrock_adapter.probe_bedrock_context_length") as mock_probe:
|
||||
assert get_bedrock_context_length("anthropic.claude-opus-4-6") == 200_000
|
||||
assert get_bedrock_context_length("anthropic.claude-opus-4-6") == 1_000_000
|
||||
mock_probe.assert_not_called()
|
||||
|
||||
|
||||
|
|
@ -1299,9 +1299,9 @@ class TestBedrockContextProbe:
|
|||
err = "AccessDeniedException: nope"
|
||||
with patch("agent.bedrock_adapter._get_bedrock_runtime_client",
|
||||
return_value=self._client_raising(err)):
|
||||
# opus-4-6 is in the table at 200K; probe fails → table wins.
|
||||
# opus-4-6 is in the table at 1M; probe fails → table wins.
|
||||
assert get_bedrock_context_length(
|
||||
"anthropic.claude-opus-4-6", region="eu-central-1") == 200_000
|
||||
"anthropic.claude-opus-4-6", region="eu-central-1") == 1_000_000
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue