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).
This commit is contained in:
kshitijk4poor 2026-07-05 21:42:19 +05:30
parent 10ced05676
commit b2c55582ef

View file

@ -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