fix(gateway): suppress pre-API compression chatter

This commit is contained in:
matt-strawbridge 2026-07-21 20:00:55 -07:00 committed by Teknium
parent 3651627d88
commit ccb5cb34a5
2 changed files with 11 additions and 0 deletions

View file

@ -82,6 +82,7 @@ _TELEGRAM_NOISY_STATUS_RE = re.compile(
r"|compacting\s+context\s+[—-]\s+summarizing\s+earlier\s+conversation"
r"|resumed\s+after\s+\d+s\s+idle\s+[—-]\s+compacting"
r"|preflight\s+compression"
r"|pre[- ]api\s+compression"
r"|session\s+compressed\s+\d+\s+times"
r"|rate\s+limited\.\s+waiting\s+\d"
r"|retrying\s+in\s+\d"

View file

@ -30,6 +30,10 @@ CHAT_PLATFORMS = [
NOISY_STATUS_MESSAGES = [
"🗜️ Preflight compression check before sending...",
(
"📦 Pre-API compression: ~123,456 tokens near the context/output limit. "
"Compacting before the next model call."
),
"🗜️ Compacting context — summarizing earlier conversation so I can continue...",
"💤 Resumed after 3600s idle — compacting ~120,000 tokens before continuing.",
"⚠️ Session compressed 12 times — accuracy may degrade. Consider /new to start fresh.",
@ -69,6 +73,12 @@ def test_programmatic_surfaces_keep_raw_status():
)
@pytest.mark.parametrize("message", ["still on it", "⏳ Working — 3 min"])
def test_telegram_status_keeps_legitimate_heartbeat_messages(message):
"""The compression filter must not swallow user-facing work heartbeats."""
assert _prepare_gateway_status_message(Platform.TELEGRAM, "lifecycle", message) == message
@pytest.mark.parametrize("platform", CHAT_PLATFORMS)
@pytest.mark.parametrize("message", NOISY_STATUS_MESSAGES)
def test_all_chat_gateways_suppress_noise(platform, message):