refactor(context): trim verbose comments

This commit is contained in:
Ahmed Allam
2026-07-26 19:26:51 +00:00
parent 95046a6cea
commit 10376b412b
6 changed files with 14 additions and 59 deletions
-2
View File
@@ -82,8 +82,6 @@ async def test_wrap_exec_command_preserves_explicit_shell(shell: str) -> None:
@pytest.mark.asyncio
async def test_responses_filesystem_custom_tool_output_is_bounded() -> None:
# In Responses-API mode filesystem tools stay native CustomTools; a large
# read must still be head+tail bounded before it enters history.
async def invoke(_ctx: Any, _inp: str) -> str:
return "line\n" * 50_000
-7
View File
@@ -121,14 +121,7 @@ def test_read_json_overrides_uses_json_when_no_alias_in_environ(tmp_path: Path)
assert loader._read_json_overrides(path) == {"llm": {"api_key": "sk-file"}}
# --------------------------------------------------------------------------- #
# ContextSettings validation
# --------------------------------------------------------------------------- #
def test_tool_output_max_bytes_rejects_sub_notice_values() -> None:
# A ceiling below the truncation notice can't fit a bounded preview, so it
# is rejected at load time rather than producing over-cap persisted output.
with pytest.raises(ValidationError):
ContextSettings(STRIX_TOOL_OUTPUT_MAX_BYTES=64)
+2 -7
View File
@@ -19,7 +19,6 @@ def test_line_limit_keeps_head_and_tail() -> None:
assert bounded.startswith("0\n1\n2\n3\n4")
assert bounded.rstrip().endswith("999")
assert "truncated" in bounded
# Head + tail only, far fewer than the original 1000 lines.
assert len(bounded.splitlines()) < 30
@@ -28,8 +27,6 @@ def test_byte_limit_enforced_on_single_long_line() -> None:
bounded = bound_text(text, max_lines=2_000, max_bytes=1_000)
assert "truncated" in bounded
# The whole joined result (head + tail + notice + separators) honours the
# configured maximum, not just the head/tail slices.
assert len(bounded.encode("utf-8")) <= 1_000
@@ -37,7 +34,7 @@ def test_multibyte_characters_not_split() -> None:
text = "😀" * 50_000
bounded = bound_text(text, max_lines=2_000, max_bytes=1_000)
# Must remain valid UTF-8 (no broken surrogate halves from a mid-char cut).
# Must remain valid UTF-8 (no mid-character cut).
assert bounded == bounded.encode("utf-8").decode("utf-8")
assert "truncated" in bounded
@@ -51,8 +48,7 @@ def test_notice_reports_dropped_counts() -> None:
def test_dropped_line_count_accounts_for_byte_trimming() -> None:
# A tight byte budget forces the byte pass to drop whole lines from the
# head/tail slices; the notice must count those, not just the middle.
# Tight byte budget drops whole lines from head/tail; the notice must count them.
text = "\n".join(f"line-{i}" for i in range(200))
bounded = bound_text(text, max_lines=20, max_bytes=40)
@@ -61,5 +57,4 @@ def test_dropped_line_count_accounts_for_byte_trimming() -> None:
dropped = int(match.group(1))
kept = [ln for ln in bounded.splitlines() if ln and "truncated" not in ln]
assert dropped == 200 - len(kept)
# The naive middle-only count (max_lines split evenly) would under-report.
assert dropped > 200 - 20