Commit db5a2ce4 by sunqi02

fix: truncate user_prompt in intent_session to prevent DB column overflow

Large text messages could cause `Data too long for column 'intent_session'`
(VARCHAR 8192) when user_prompt is serialized to JSON. Truncate to 2000 chars
before writing to DB, keeping the full text for LLM classification unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent b89eac47
......@@ -269,7 +269,10 @@ class MessageGate:
content = (m.get("content") or "").strip()
if m.get("role") != "system" and "## 当前用户消息" not in content and content:
intent_session.append({"role": m["role"], "content": m.get("content", "")})
intent_session.append({"role": "user", "content": user_prompt})
# 截断超长 user_prompt,防止 intent_session 列写入超限(VARCHAR 8192)
MAX_USER_PROMPT = 2000
stored_prompt = user_prompt if len(user_prompt) <= MAX_USER_PROMPT else user_prompt[:MAX_USER_PROMPT] + "...[已截断]"
intent_session.append({"role": "user", "content": stored_prompt})
data["intent_session"] = intent_session
store.set(session_id, data)
self.session_service.save_to_db(session_id)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!