Skip to content

Commit f23d255

Browse files
committed
fix: add min_length=20 to avoid affecting short tool names like pingping
1 parent 11e823e commit f23d255

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

astrbot/core/provider/sources/openai_source.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ def _truncate_error_text_candidate(cls, text: str) -> str:
6363
return text[: cls._ERROR_TEXT_CANDIDATE_MAX_CHARS]
6464

6565
@staticmethod
66-
def _deduplicate_self_repeating(value: str | None) -> str | None:
67-
"""If string is a self-repeating pattern like 'abcabc' (exactly 2 repetitions),
68-
return the base unit. This handles streaming chunk duplication issues.
66+
def _deduplicate_self_repeating(value: str | None, min_length: int = 20) -> str | None:
67+
"""If string is a self-repeating pattern like 'astr_kb_searchastr_kb_search'
68+
(exactly 2 repetitions, min 20 chars), return the base unit.
69+
This handles streaming chunk duplication issues for tool names/IDs.
6970
Returns None unchanged."""
7071
if value is None:
7172
return None
72-
if not value or len(value) < 4:
73+
if not value or len(value) < min_length:
7374
return value
7475
half = len(value) // 2
7576
if value[:half] == value[half:]:

0 commit comments

Comments
 (0)