fix: preserve tool failures under noisy output
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from agent_platform.text import truncate_middle
|
||||
|
||||
|
||||
def test_truncate_middle_preserves_error_at_end() -> None:
|
||||
text = "stdout:" + ("x" * 1000) + "\nNameError: start is not defined"
|
||||
|
||||
truncated = truncate_middle(text, 120)
|
||||
|
||||
assert len(truncated) == 120
|
||||
assert truncated.startswith("stdout:")
|
||||
assert "middle omitted" in truncated
|
||||
assert truncated.endswith("NameError: start is not defined")
|
||||
|
||||
|
||||
def test_truncate_middle_leaves_short_text_unchanged() -> None:
|
||||
assert truncate_middle("short", 20) == "short"
|
||||
|
||||
|
||||
def test_truncate_middle_honors_tiny_limits() -> None:
|
||||
marker = "<omitted>"
|
||||
|
||||
assert truncate_middle("abcdef", 0, marker) == ""
|
||||
assert truncate_middle("abcdef", 3, marker) == "abc"
|
||||
assert truncate_middle("abcdefghijklmnopqrstuvwxyz", len(marker) + 1, marker) == "a<omitted>"
|
||||
Reference in New Issue
Block a user