Version: 0.8.3.dev.260328
后端: 1.彻底删除原agent文件夹,并将现agent2文件夹全量重命名为agent(包括全部涉及到的文件以及文档、注释),迁移工作完美结束 2.修复了重试消息的相关逻辑问题 前端: 1.改善了一些交互体验,修复了一些bug,现在只剩少的功能了,现存的bug基本都修复完毕 全仓库: 1.更新了决策记录和README文档
This commit is contained in:
@@ -46,7 +46,7 @@ func (s *AgentService) GetConversationHistory(ctx context.Context, userID int, c
|
||||
items, cacheErr := s.cacheDAO.GetConversationHistoryFromCache(ctx, userID, normalizedChatID)
|
||||
if cacheErr != nil {
|
||||
log.Printf("读取会话历史视图缓存失败 chat_id=%s: %v", normalizedChatID, cacheErr)
|
||||
} else if items != nil {
|
||||
} else if conversationHistoryCacheCanServe(items) {
|
||||
return items, nil
|
||||
}
|
||||
}
|
||||
@@ -228,6 +228,18 @@ func normalizeConversationHistoryRole(role string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func conversationHistoryCacheCanServe(items []model.GetConversationHistoryItem) bool {
|
||||
// 1. 历史接口一旦被前端用于“重试/编辑”等二次动作,消息 id 就必须稳定可追溯。
|
||||
// 2. 乐观缓存里的新消息在 DB 落库前没有自增主键,若直接返回,会让前端拿到占位 id。
|
||||
// 3. 因此只有“缓存里的每条消息都带稳定 DB id”时,才允许直接命中缓存;否则强制回源 DB。
|
||||
for _, item := range items {
|
||||
if item.ID <= 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return items != nil
|
||||
}
|
||||
|
||||
func buildOptimisticConversationHistoryItem(
|
||||
role string,
|
||||
content string,
|
||||
|
||||
Reference in New Issue
Block a user