mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 23:47:54 +08:00
core/agent: drop increase-limit hint in favor of truncate tokens
This commit is contained in:
@@ -50,7 +50,7 @@ def truncate_tool_result(
|
|||||||
return (
|
return (
|
||||||
f"{text[:max_chars]}\n"
|
f"{text[:max_chars]}\n"
|
||||||
f"...[Truncated ({max_chars} chars max.; {omitted} chars omitted). "
|
f"...[Truncated ({max_chars} chars max.; {omitted} chars omitted). "
|
||||||
f"You may ask for user to increase the limit via configuration file.]"
|
f"Use `get_truncated` when a `TRUNCATE_TOKEN` is shown.]"
|
||||||
)
|
)
|
||||||
return f"{text[:max_chars]}\n...[truncated {omitted} characters]"
|
return f"{text[:max_chars]}\n...[truncated {omitted} characters]"
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ def test_truncate_tool_result_long() -> None:
|
|||||||
assert "Truncated" in out
|
assert "Truncated" in out
|
||||||
assert "20" in out
|
assert "20" in out
|
||||||
assert "30" in out
|
assert "30" in out
|
||||||
assert "configuration file" in out
|
assert "get_truncated" in out
|
||||||
|
assert "configuration file" not in out
|
||||||
|
|
||||||
|
|
||||||
def test_truncate_tool_result_no_hint() -> None:
|
def test_truncate_tool_result_no_hint() -> None:
|
||||||
@@ -23,7 +24,7 @@ def test_truncate_tool_result_no_hint() -> None:
|
|||||||
out = truncate_tool_result(text, 20, hint=False)
|
out = truncate_tool_result(text, 20, hint=False)
|
||||||
assert out.startswith("a" * 20)
|
assert out.startswith("a" * 20)
|
||||||
assert "truncated" in out
|
assert "truncated" in out
|
||||||
assert "configuration file" not in out
|
assert "get_truncated" not in out
|
||||||
|
|
||||||
|
|
||||||
def test_estimate_message_chars() -> None:
|
def test_estimate_message_chars() -> None:
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ def test_truncate_tool_result_long() -> None:
|
|||||||
assert "Truncated" in out
|
assert "Truncated" in out
|
||||||
assert "20" in out
|
assert "20" in out
|
||||||
assert "30" in out
|
assert "30" in out
|
||||||
assert "configuration file" in out
|
assert "get_truncated" in out
|
||||||
|
assert "configuration file" not in out
|
||||||
|
|
||||||
|
|
||||||
def test_truncate_tool_result_no_hint() -> None:
|
def test_truncate_tool_result_no_hint() -> None:
|
||||||
@@ -52,7 +53,7 @@ def test_truncate_tool_result_no_hint() -> None:
|
|||||||
out = truncate_tool_result(text, 20, hint=False)
|
out = truncate_tool_result(text, 20, hint=False)
|
||||||
assert out.startswith("a" * 20)
|
assert out.startswith("a" * 20)
|
||||||
assert "truncated" in out
|
assert "truncated" in out
|
||||||
assert "configuration file" not in out
|
assert "get_truncated" not in out
|
||||||
|
|
||||||
|
|
||||||
def test_compact_shrinks_old_tool_results() -> None:
|
def test_compact_shrinks_old_tool_results() -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user