From 60b99e1932b93aaf24c47eb7f7c07fd0bd26636e Mon Sep 17 00:00:00 2001 From: qqx <1542452647@qq.com> Date: Tue, 22 Sep 2026 17:17:12 +0800 Subject: [PATCH] fix(compression): enable native compaction for Astra 900K alias (cherry picked from commit 8ce2851f0495db8afb44118928f4c3695bb12e06) --- agent/native_compaction.py | 13 ++++++++++--- tests/agent/test_native_compaction.py | 7 +++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/agent/native_compaction.py b/agent/native_compaction.py index d8ae08348a..f5224cb0e5 100644 --- a/agent/native_compaction.py +++ b/agent/native_compaction.py @@ -26,15 +26,22 @@ LOCAL_TRIGGER_SAFETY_MARGIN = 8_192 DEFAULT_COMPACT_THRESHOLD = 200_000 # Substring match so dated snapshots and variants (gpt-5.6-mini) stay eligible. _ELIGIBLE_MODEL_MARKER = "gpt-5.6" +_ASTRA_NATIVE_COMPACTION_MODELS = frozenset({"gpt-6-astra", "gpt-6-astra-900k"}) def is_native_compaction_model( model: Optional[str], *, provider: Optional[str] = None, base_url: Optional[str] = None, ) -> bool: - """Preserve gpt-5.6 eligibility; Astra additionally requires official Codex OAuth.""" - model_name = (model or "").lower() + """Preserve gpt-5.6 eligibility; Astra additionally requires official Codex OAuth. + + ``-900k`` is Hermes' local picker alias and is stripped before the request is + sent. It must retain the same native-compaction eligibility as the bare + Astra wire model; otherwise enabling the feature in a 900K session is a + silent no-op. + """ + model_name = (model or "").strip().lower().rsplit("/", 1)[-1] return _ELIGIBLE_MODEL_MARKER in model_name or ( - model_name == "gpt-6-astra" + model_name in _ASTRA_NATIVE_COMPACTION_MODELS and (provider or "").strip().lower() == "openai-codex" and is_official_codex_base_url(base_url or "") ) diff --git a/tests/agent/test_native_compaction.py b/tests/agent/test_native_compaction.py index a6fc019711..5810fa6731 100644 --- a/tests/agent/test_native_compaction.py +++ b/tests/agent/test_native_compaction.py @@ -46,6 +46,13 @@ class TestModelGate: assert is_native_compaction_model("gpt-5.6-mini") assert is_native_compaction_model("GPT-5.6-2026-07-15") + def test_astra_900k_picker_alias_is_eligible_on_official_codex_oauth(self): + assert is_native_compaction_model( + "gpt-6-astra-900k", + provider="openai-codex", + base_url="https://chatgpt.com/backend-api/codex", + ) + def test_other_models_ineligible(self): # gpt-5.1/5.2 fail server-side on context_management (live-verified); # gpt-5.3-codex works upstream but is outside the supported set.