fix: storeThought orphaned lock → defer unlock

This commit is contained in:
2026-06-28 16:16:35 +08:00
parent dc410c1cff
commit 24d7722ef9
@@ -1895,6 +1895,7 @@ func (t *Thinker) buildOpenAITools() []llm.OpenAITool {
// storeThought 存储思考结果到待推送队列,并异步持久化到 memory-service
func (t *Thinker) storeThought(content string, toolCallsJSON string, toolCallCount int) {
t.muLock()
defer t.muUnlock()
t.pendingThoughts = append(t.pendingThoughts, &PendingThought{
Content: content,
CreatedAt: time.Now(),
@@ -1951,7 +1952,6 @@ func (t *Thinker) storeThought(content string, toolCallsJSON string, toolCallCou
copy := *proactiveTarget
targetCopy = &copy
}
t.muUnlock()
log.Printf("[后台思考] 思考已存储 (当前累积 %d 条待推送思考)", len(t.pendingThoughts))