refactor: make truncate method accept maxLen parameter

The truncate method now accepts a maxLen parameter instead of using
the hardcoded MAX_TEXT_LEN constant. This allows different types of
content to use different truncation lengths. Note: calling sites will
need to be updated to pass the maxLen parameter.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
everywhere.z
2026-05-16 23:30:28 +08:00
parent ab0efe6bd1
commit fbeab8b880

View File

@@ -101,9 +101,9 @@ public class ReActLoggingHook implements Hook {
return sb.toString();
}
private static String truncate(String s) {
private static String truncate(String s, int maxLen) {
if (s == null) return "";
s = s.replaceAll("\\s+", " ").trim();
return s.length() <= MAX_TEXT_LEN ? s : s.substring(0, MAX_TEXT_LEN) + "...(truncated)";
return s.length() <= maxLen ? s : s.substring(0, maxLen) + "...(truncated)";
}
}