test(compression): resolve context_length inside mock in overflow-warning fixture

CI shard 4 caught 4 failures the local baseline diff missed (local env
pollution made them look pre-existing): _make_compressor() constructs
under a get_model_context_length mock but the lazy deferral (#32221)
pushed resolution past the with block, so the 96K window / 75% floor the
tests rely on never materialized. Resolve inside the mock.
This commit is contained in:
kshitijk4poor 2026-07-28 19:25:45 +05:00 committed by kshitij
parent 49f50c68a0
commit 2e9559adf0
1 changed files with 4 additions and 1 deletions

View File

@ -34,7 +34,10 @@ def _make_compressor(**kwargs) -> ContextCompressor:
# 96K context -> small-context floor raises threshold_percent to 0.75,
# so threshold_tokens = 72_000. 73_000 is "over threshold".
with patch("agent.context_compressor.get_model_context_length", return_value=96000):
return ContextCompressor(**defaults)
comp = ContextCompressor(**defaults)
# Resolve while the mock is active (lazy init, #32221).
_ = comp.context_length
return comp
class TestShouldCompressInfo: