fix(backthink): 主动推送也落主会话上下文——修复回复时上下文断片
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

bridge.SendProactive 之前只发送不落历史,导致她主动说的话不在主会话 chat_messages,
你回复时 LLM 看不到她的主动消息→上下文不连贯。现发送后 persistToMain 镜像到主会话
(assistant+platform+deviceID),你回复时上下文带上她的主动消息。build/test 全绿。
This commit is contained in:
Aska committed 2026-09-07 20:18:03 +08:00
1 parent c4fe5a0cfd
commit 06fd2f4aaf
1 file changed
+8
@@ -6,6 +6,7 @@ import (
"strings"
"git.yeij.top/AskaEth/Cyrene_v2/internal/channel/adapter"
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/history"
)
// proactiveTarget is the owner's IM address (platform + account id) resolved for
@@ -46,6 +47,13 @@ func (b *Bridge) SendProactive(ctx context.Context, msg adapter.UnifiedMessage)
if err := ad.SendProactive(ctx, out); err != nil {
return fmt.Errorf("channelbridge: send proactive via %q: %w", target.platform, err)
}
// Mirror the proactive message into the main conversation context (design/16
// §4.4 + §4.6.1). Without this the model would not see what it proactively said, so
// a follow-up owner reply would feel incoherent (the message "loses" its history).
// It is the same mirror path as owner-private IM replies, scoped to MainSessionID.
b.persistToMain(ctx, history.RoleAssistant, msg.Content, target.platform,
fmt.Sprintf("%s:%s:%s", target.platform, target.accountID, target.accountID),
target.platform)
return nil
}