test(compression): pin rotation-fallback tests to in_place=False ahead of default flip

These 7 test sites assert rotation behavior (fork, child sessions, lock
contention, logging session-context follows id rotation, boundary hooks fire
on rotation). Pin each builder to in_place=False explicitly so they keep
exercising the retained rotation fallback regardless of the global default
(flipped to True in #38763). Rotation stays a working opt-out fallback and
deserves continued coverage — these are NOT deleted.

Pinned sites:
- test_compression_concurrent_fork._build_agent_with_db
- test_compression_logging_session_context._build_agent_with_db
- test_compression_rotation_state._build_agent_with_db
- test_compression_boundary_hook._make_agent (2 helpers: CompressionBoundaryHook + SessionCompressEvent)
- test_compression_concurrent_sessions._build_agent_with_db
This commit is contained in:
kshitijk4poor 2026-06-24 20:22:05 +05:30 committed by Teknium
parent 2107b86024
commit d9bd7ce827
6 changed files with 31 additions and 6 deletions

View file

@ -77,6 +77,10 @@ def _build_agent_with_db(db: SessionDB, session_id: str):
compressor._last_aux_model_failure_model = None
compressor._last_aux_model_failure_error = None
agent.context_compressor = compressor
# These tests cover the ROTATION fallback path (forking, child sessions,
# lock contention) — pin in_place=False so they keep exercising it
# regardless of the global default (which flipped to True in #38763).
agent.compression_in_place = False
return agent

View file

@ -50,6 +50,10 @@ def _build_agent_with_db(db: SessionDB, session_id: str):
compressor._last_aux_model_failure_model = None
compressor._last_aux_model_failure_error = None
agent.context_compressor = compressor
# This test covers the ROTATION fallback (logging session-context follows
# the id rotation) — pin in_place=False so it keeps exercising rotation
# regardless of the global default (flipped to True in #38763).
agent.compression_in_place = False
return agent

View file

@ -54,6 +54,9 @@ def _build_agent_with_db(db: SessionDB, session_id: str, platform: str = "telegr
compressor._last_aux_model_failure_model = None
compressor._last_aux_model_failure_error = None
agent.context_compressor = compressor
# ROTATION fallback path — pin in_place=False so these keep covering fork
# rotation regardless of the global default (flipped to True in #38763).
agent.compression_in_place = False
return agent

View file

@ -71,6 +71,10 @@ def _build_agent_with_db(db: SessionDB, session_id: str):
compressor._last_aux_model_failure_model = None
compressor._last_aux_model_failure_error = None
agent.context_compressor = compressor
# ROTATION fallback path — pin in_place=False so these keep covering the
# concurrent-rotation lock contract regardless of the global default
# (flipped to True in #38763).
agent.compression_in_place = False
return agent

View file

@ -22,7 +22,7 @@ class TestCompressionBoundaryHook:
def _make_agent(self, session_db):
with patch.dict(os.environ, {"OPENROUTER_API_KEY": "test-key"}):
from run_agent import AIAgent
return AIAgent(
agent = AIAgent(
api_key="test-key",
base_url="https://openrouter.ai/api/v1",
model="test/model",
@ -32,6 +32,9 @@ class TestCompressionBoundaryHook:
skip_context_files=True,
skip_memory=True,
)
# ROTATION fallback — pin in_place=False regardless of default (#38763).
agent.compression_in_place = False
return agent
def test_on_session_start_called_with_compression_boundary(self):
from hermes_state import SessionDB
@ -167,7 +170,7 @@ class TestSessionCompressEvent:
def _make_agent(self, session_db, event_callback=None):
with patch.dict(os.environ, {"OPENROUTER_API_KEY": "test-key"}):
from run_agent import AIAgent
return AIAgent(
agent = AIAgent(
api_key="test-key",
base_url="https://openrouter.ai/api/v1",
model="test/model",
@ -178,6 +181,9 @@ class TestSessionCompressEvent:
skip_memory=True,
event_callback=event_callback,
)
# ROTATION fallback — pin in_place=False regardless of default (#38763).
agent.compression_in_place = False
return agent
def _stub_compressor(self):
compressor = MagicMock()

View file

@ -184,9 +184,11 @@ class TestInPlaceCompaction:
assert calls["n"] == 1
class TestRotationStillDefault:
class TestRotationFallbackWhenFlagOff:
def test_rotation_when_flag_off(self):
"""Regression guard: flag off => legacy rotation is unchanged."""
"""Rotation is now the OPT-OUT fallback (default flipped to in-place in
#38763). With in_place=False explicitly set, legacy rotation is
unchanged forks a renamed continuation session."""
from hermes_state import SessionDB
from agent.conversation_compression import compress_context
@ -247,10 +249,12 @@ class TestInPlaceSignalForGateway:
class TestInPlaceConfigDefault:
def test_flag_defaults_off(self):
def test_flag_defaults_on(self):
"""In-place is the default as of #38763 (rotation is now opt-out via
compression.in_place: false)."""
from hermes_cli.config import DEFAULT_CONFIG
assert DEFAULT_CONFIG["compression"].get("in_place") is False
assert DEFAULT_CONFIG["compression"].get("in_place") is True
class TestCompactedTurnsStaySearchable: