fix(utils): avoid hang in split_message when max_len <= 0
When max_len is 0 or negative the cut pointer never advances, so the loop hangs. Return the content unsplit, matching truncate_text_to_tokens for non-positive budgets.
This commit is contained in:
@@ -526,6 +526,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] = []
|
||||
|
||||
Reference in New Issue
Block a user