From c0d2ed68f700086f51c9dc2442b5aea4142b94ea Mon Sep 17 00:00:00 2001 From: Wesley Simplicio Date: Sat, 9 May 2026 10:35:08 -0300 Subject: [PATCH] fix(model-metadata): align hy3-preview static context length with OpenRouter Problem: test_hy3_preview_context_length asserted ctx == 256000 but OpenRouter live metadata reports 262144 (256 * 1024) for tencent/hy3-preview. Static DEFAULT_CONTEXT_LENGTHS fallback held 256000, so the assertion flipped depending on whether the live cache was warm. Issue #22268. Root cause: DEFAULT_CONTEXT_LENGTHS["hy3-preview"] = 256000 was authored before OpenRouter exposed the precise 256K boundary. The static fallback now diverges from the authoritative live value, producing intermittent test failures and (more importantly) a 6KB slice of dropped context when the live cache is unavailable (CI w/o network, offline runs). Fix: Bump the static fallback to 262144 to match OpenRouter live metadata. Comment cites the issue so future readers know why the magic number isn't a round 256000. Tests: - Update test_hy3_preview_context_length to assert 262144. - Add test_hy3_preview_static_fallback_matches_live which asserts against DEFAULT_CONTEXT_LENGTHS directly, so the regression catches drift even when the live cache shadows the static table. Stash-verify confirmed: reverting the static value alone fails the new static-table test (assert 256000 == 262144). --- agent/model_metadata.py | 6 ++++-- tests/hermes_cli/test_tencent_tokenhub_provider.py | 14 +++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/agent/model_metadata.py b/agent/model_metadata.py index 4df8a6077791..40fbae33a68b 100644 --- a/agent/model_metadata.py +++ b/agent/model_metadata.py @@ -210,8 +210,10 @@ def _strip_provider_prefix(model: str) -> str: "grok": 131072, # catch-all (grok-beta, unknown grok-*) # Kimi "kimi": 262144, - # Tencent — Hy3 Preview (Hunyuan) with 256K context window - "hy3-preview": 256000, + # Tencent — Hy3 Preview (Hunyuan) with 256K context window. + # OpenRouter live metadata reports 262144 (256 * 1024); aligning the + # static fallback so cache and fallback agree (issue #22268). + "hy3-preview": 262144, # Nemotron — NVIDIA's open-weights series (128K context across all sizes) "nemotron": 131072, # Arcee diff --git a/tests/hermes_cli/test_tencent_tokenhub_provider.py b/tests/hermes_cli/test_tencent_tokenhub_provider.py index 62cecaeb0c31..2e5e18810c87 100644 --- a/tests/hermes_cli/test_tencent_tokenhub_provider.py +++ b/tests/hermes_cli/test_tencent_tokenhub_provider.py @@ -309,7 +309,19 @@ class TestTencentTokenhubContextLength: def test_hy3_preview_context_length(self): from agent.model_metadata import get_model_context_length ctx = get_model_context_length("hy3-preview") - assert ctx == 256000 + # OpenRouter live API returns 262144 (256 * 1024); static fallback + # tracks the same value so tests pass whether resolution comes from + # live cache or static table (issue #22268). + assert ctx == 262144 + + def test_hy3_preview_static_fallback_matches_live(self): + """Static DEFAULT_CONTEXT_LENGTHS entry must match OpenRouter live (issue #22268). + + Pins the static value so this stays correct even when the live cache + is unavailable in test environments (CI without network). + """ + from agent.model_metadata import DEFAULT_CONTEXT_LENGTHS + assert DEFAULT_CONTEXT_LENGTHS["hy3-preview"] == 262144 # =============================================================================