From b2c55582efb365bca5b0d99d20c8d8161fecde79 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 5 Jul 2026 21:42:19 +0530 Subject: [PATCH] test(compressor): drop source-string guardrail tests The two TestSourceGuardrail tests asserted the presence of literal strings ("#58753", "_user_survives") in context_compressor.py. Those are change-detector tests that break on any refactor without catching a real regression. The four behavioral tests in TestCompressAlwaysKeepsAUserTurn already exercise the real compress() path and fully cover the invariant (user turn survives, summary pinned to user, no consecutive user roles, surviving tail user untouched). --- .../agent/test_compressor_zero_user_guard.py | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/tests/agent/test_compressor_zero_user_guard.py b/tests/agent/test_compressor_zero_user_guard.py index 9e14a80925a..e5e3c59286f 100644 --- a/tests/agent/test_compressor_zero_user_guard.py +++ b/tests/agent/test_compressor_zero_user_guard.py @@ -178,29 +178,3 @@ class TestCompressAlwaysKeepsAUserTurn: m.get("content") for m in out if isinstance(m.get("content"), str) ) assert "the latest live user question" in joined - - -class TestSourceGuardrail: - @pytest.fixture - def source(self) -> str: - from pathlib import Path - - return ( - Path(__file__).resolve().parents[2] - / "agent" - / "context_compressor.py" - ).read_text(encoding="utf-8") - - def test_zero_user_guard_present(self, source): - assert "#58753" in source - # The guard must consider messages OUTSIDE the (system-only) head - # case — i.e. it inspects the preserved tail for a surviving user. - assert "_user_survives" in source - - def test_guard_wired_into_force_user_leading(self, source): - """The guard must feed ``_force_user_leading`` so the existing - flip logic cannot revert the summary back to assistant.""" - idx_guard = source.find("_user_survives") - idx_force = source.rfind("_force_user_leading = True") - assert idx_guard >= 0 and idx_force >= 0 - assert idx_force > idx_guard