"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(channels): avoid hang in split_message when max_len <= 0
santhreal78d51b4eb5bb
diff --git a/agent/src/channels/utils.py b/agent/src/channels/utils.pyindex 8c792e10f..e01fd941f 100644--- a/agent/src/channels/utils.py+++ b/agent/src/channels/utils.py@@ -62,6 +62,9 @@ def split_message(content: str, max_len: int = 2000) -> list[str]:"""if not content:return []+ # Non-positive max_len cannot advance the cut pointer; return unsplit.+ if max_len <= 0:+ return [content]if len(content) <= max_len:return [content]chunks: list[str] = []diff --git a/agent/tests/test_split_message_nonpositive.py b/agent/tests/test_split_message_nonpositive.pynew file mode 100644index 000000000..bac6ddb45--- /dev/null+++ b/agent/tests/test_split_message_nonpositive.py@@ -0,0 +1,17 @@+"""Regression: split_message must not hang on non-positive max_len."""++from __future__ import annotations++from src.channels.utils import split_message+++def test_split_message_nonpositive_max_len_returns_unsplit() -> None:+ content = "hello world"+ assert split_message(content, max_len=0) == [content]+ assert split_message(content, max_len=-1) == [content]+++def test_split_message_normal_path() -> None:+ chunks = split_message("aaa\nbbb\nccc", max_len=5)+ assert chunks+ assert all(len(c) <= 5 for c in chunks)