The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(agent): trim #121548 tests to the two invariants
kshitijk4poor70203f77524d
diff --git a/tests/agent/test_compression_marker.py b/tests/agent/test_compression_marker.pyindex e76c84d13f6..e35e63bb3f0 100644--- a/tests/agent/test_compression_marker.py+++ b/tests/agent/test_compression_marker.py@@ -3,8 +3,8 @@The bare bracketed truncation idiom those renderers used to compose was imitatedfrom replayed context into new durable writes (see #83435/#83714). All elision nowroutes through ``agent.compression_marker.elide`` / ``elide_middle``, and this file-pins both the helpers and the source-level invariant that the imitable idiom never-returns to ``agent/`` strings.+pins guard parity and the source-level invariant that the imitable idiom never+returns to agent-facing strings."""from __future__ import annotations@@ -13,7 +13,6 @@ import reimport tokenizefrom agent.compression_marker import (- _COMPRESSION_MARKER_PREFIX,_COMPRESSION_MARKER_RE,elide,elide_middle,@@ -31,41 +30,10 @@ SCANNED_PATHS = (IMITABLE_MARKER_RE = re.compile(r"(?:\.\.\.|…)\s?\[[^\]\n]*truncated\]")-class TestElide:- def test_text_that_fits_is_returned_unchanged(self):- assert elide("hello", 5) == "hello"- assert elide("hello", 100) == "hello"-- def test_elided_text_is_capped_with_accurate_counts(self):- text = "x" * 5000- out = elide(text, 700)- assert len(out) <= 700- kept = out.split(_COMPRESSION_MARKER_PREFIX, 1)[0]- assert kept and kept == "x" * len(kept)- omitted = len(text) - len(kept)- assert f"{omitted:,} of 5,000 chars omitted" in out- assert out.endswith("⟫")-- def test_result_never_exceeds_limit(self):- for limit in (150, 199, 700, 1400, 4000):- assert len(elide("z" * 100_000, limit)) <= limit-- def test_minted_marker_is_caught_by_the_dispatch_boundary_guard(self):- """A copied marker must refuse a durable write regardless of which renderer leaked it."""- for out in (elide("y" * 4000, 199), elide_middle("y" * 4000, 100, 100)):- assert _COMPRESSION_MARKER_RE.search(out)---class TestElideMiddle:- def test_keeps_head_and_tail_and_reports_the_middle(self):- text = "a" * 100 + "b" * 5000 + "c" * 100- out = elide_middle(text, 100, 100)- assert out.startswith("a" * 100)- assert out.endswith("c" * 100)- assert "5,000 of 5,200 chars omitted" in out-- def test_short_text_is_returned_unchanged(self):- assert elide_middle("short", 3, 3) == "short"+def test_minted_marker_is_caught_by_the_dispatch_boundary_guard():+ """A copied marker must refuse a durable write regardless of which renderer leaked it."""+ for out in (elide("y" * 4000, 199), elide_middle("y" * 4000, 100, 100)):+ assert _COMPRESSION_MARKER_RE.search(out)def test_no_imitable_truncation_marker_in_agent_strings():diff --git a/tests/agent/test_skill_inline_shell_output.py b/tests/agent/test_skill_inline_shell_output.pyindex f791b324155..c9250565729 100644--- a/tests/agent/test_skill_inline_shell_output.py+++ b/tests/agent/test_skill_inline_shell_output.py@@ -10,12 +10,3 @@ def test_silent_nonzero_exit_returns_marker(tmp_path):def test_nonzero_exit_with_stderr_keeps_the_diagnostic(tmp_path):assert run_inline_shell('printf "diag" >&2; exit 3', tmp_path, 5) == "diag"--def test_long_output_is_elided_with_non_imitable_marker(tmp_path):- """#121548: inline-shell output is embedded into skill bodies on every load."""- from agent.skill_preprocessing import _INLINE_SHELL_MAX_OUTPUT-- out = run_inline_shell("printf 'a%.0s' {1..5000}", tmp_path, 5)- assert len(out) <= _INLINE_SHELL_MAX_OUTPUT- assert "HERMES-CONTEXT-COMPRESSION" in out- assert out.endswith("⟫")