feat(hub): rolling chat summary to cap AI context and prevent mid-session failures

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-11 21:51:34 +08:00
parent 180aff5310
commit 6a1f2608b5
9 changed files with 297 additions and 50 deletions
+14
View File
@@ -0,0 +1,14 @@
"""中控 AI 文本小工具。"""
def is_ai_error_reply(text: str) -> bool:
t = (text or "").strip()
return t.startswith("AI 调用失败") or t.startswith("AI 生成失败")
def clip_text(text: str, max_chars: int) -> str:
s = str(text or "").strip()
limit = max(200, int(max_chars or 0))
if len(s) <= limit:
return s
return s[: limit - 1].rstrip() + ""