fix: 后台思考身份混淆 + 静默模式视觉理解 + QQ卡片解析 + 仪表盘状态修复
- 后台思考对话历史增加标签说明,严格区分群聊中不同发送者 - 静默观察模式传入图片URL并预处理,供后台思考参考 - 视觉+OCR双模型结果合并格式优化,避免LLM误认为多张图片 - QQ卡片消息(CQ:json)正确解析标题/类型,不再丢失为[JSON] - 进程管理器stop()在进程为null时重置pid/startTime,消除矛盾状态 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1177,8 +1177,11 @@ func (t *Thinker) buildThinkingUserPrompt(
|
||||
|
||||
// 对话历史
|
||||
var lastUserMsg string
|
||||
lastUserIsAdmin := false
|
||||
if len(convHistory) > 0 {
|
||||
sb.WriteString("\n【最近的对话】\n")
|
||||
sb.WriteString(fmt.Sprintf("(标签说明:每条消息前的 [名字] 标识了说话者。只有 [%s] 才是%s。其他名字是群聊中的其他成员,不是%s。请严格根据标签区分不同的人,不要张冠李戴。)\n",
|
||||
t.adminNickname, t.adminNickname, t.adminNickname))
|
||||
msgCount := 0
|
||||
for _, msg := range convHistory {
|
||||
if msg.Role == model.RoleUser || msg.Role == model.RoleAssistant {
|
||||
@@ -1187,6 +1190,8 @@ func (t *Thinker) buildThinkingUserPrompt(
|
||||
roleLabel = "昔涟"
|
||||
} else if strings.Contains(msg.Content, t.adminNickname+"/") {
|
||||
roleLabel = t.adminNickname
|
||||
} else if name := extractGroupSender(msg.Content); name != "" {
|
||||
roleLabel = name
|
||||
}
|
||||
content := msg.Content
|
||||
runes := []rune(content)
|
||||
@@ -1197,18 +1202,19 @@ func (t *Thinker) buildThinkingUserPrompt(
|
||||
msgCount++
|
||||
if msg.Role == model.RoleUser {
|
||||
lastUserMsg = msg.Content
|
||||
lastUserIsAdmin = roleLabel == t.adminNickname
|
||||
}
|
||||
}
|
||||
}
|
||||
if msgCount == 0 {
|
||||
sb.WriteString("(暂无对话历史)\n")
|
||||
sb.WriteString("(暂无对话历史)\n")
|
||||
}
|
||||
} else {
|
||||
sb.WriteString("\n【最近的对话】\n(暂无对话历史)\n")
|
||||
}
|
||||
|
||||
// 关键:强调根据对话历史判断用户当前状态
|
||||
if lastUserMsg != "" {
|
||||
// 关键:强调根据对话历史判断当前状态
|
||||
if lastUserMsg != "" && lastUserIsAdmin {
|
||||
sb.WriteString(fmt.Sprintf("\n🔍 **重要**:开拓者最后说的是「%s」。请认真判断:他现在是不是在休息/睡觉/忙?如果是,不要输出【主动消息】指令行。\n", lastUserMsg))
|
||||
}
|
||||
|
||||
@@ -1821,6 +1827,27 @@ func (t *Thinker) expandMemoryKeywords(ctx context.Context, message string) []st
|
||||
return keywords
|
||||
}
|
||||
|
||||
// extractGroupSender extracts the sender name from a group message prefix.
|
||||
// Group messages have the format: [群聊 GROUPID] SENDERNAME (UID):\ncontent
|
||||
// Returns empty string if the message doesn't match the group format.
|
||||
func extractGroupSender(content string) string {
|
||||
if !strings.HasPrefix(content, "[群聊 ") {
|
||||
return ""
|
||||
}
|
||||
// Find "] " which ends the group label
|
||||
bracketEnd := strings.Index(content, "] ")
|
||||
if bracketEnd < 0 {
|
||||
return ""
|
||||
}
|
||||
rest := content[bracketEnd+2:]
|
||||
// Find " (" which precedes the UID
|
||||
parenIdx := strings.Index(rest, " (")
|
||||
if parenIdx < 0 {
|
||||
return ""
|
||||
}
|
||||
return rest[:parenIdx]
|
||||
}
|
||||
|
||||
// lastUserMessage extracts the last user message from conversation history.
|
||||
func lastUserMessage(history []model.LLMMessage) string {
|
||||
for i := len(history) - 1; i >= 0; i-- {
|
||||
|
||||
Reference in New Issue
Block a user