fix(upstream): M51 复审 p2 三条 —— light.go 同形出口 / MCP SDK 日志面 / ErrorToken 口径
① light.go 的 2 处 "light judge: " + d.Reason 与 engage.go 同形(model reason → 返回值 → coalesce_prepare 的 Debug)。把上一轮的 engageReason 提成包内共用的 judgeReason(judge_reason.go,RedactTextLimited + strings.Fields,60 rune), engage.go 7 处 + light.go 2 处 + notice.go 的 "notice review failed: "+err.Error() 统一走它。控制流零改动:只换「进去的那份文本」,判定条件与返回值拼接结构未动。 ② MCP 的 Logger 面先探针后修:go-sdk v1.8.0 的 keepalive 会把对端 JSON-RPC error 原样打进日志(实测泄漏,见 sdklog_probe_test.go 的输出),tools/call 路径不打日志。 新增 sdklog.go:redactingLogger 交给 SDK,wire 错误(链上有 *jsonrpc.Error)只留 code + message_bytes(复用 upstreamError),本地错误保留原因,消息/属性压平+打码+300 rune。 ③ errortoken.go 的口径注释纠正:从「包外不得调用」改为按字段类别判定(协议枚举可守、 自由文本默认不带),并把 cdp.go 这条 M51 用法作为例子写进去。
This commit is contained in:
1 parent
7fbb8d6232
commit
76263d42ed
11 files changed
+560
-47
No files matched your search
@@ -10,7 +10,6 @@ import (
|
||||
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/channel/adapter"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/channel/session"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/trace"
|
||||
)
|
||||
|
||||
// 本文件承载公开平台群聊/陌生人会话的参与度引擎
|
||||
@@ -59,29 +58,6 @@ const (
|
||||
// 因此它失败关闭为静默。
|
||||
var errNoEngageJudge = errors.New("channelbridge: no light judge wired for engage")
|
||||
|
||||
// engageReasonRunes 是判定器 reason 允许出镜的 rune 上限。
|
||||
//
|
||||
// 取 60 的理由:reason 由「只输出 JSON 对象」的轻量判定器给出,实际值是一句短语
|
||||
// (「群里在聊周末安排,与角色无关」≈ 16 字),60 rune 容得下三四句这样的短语;
|
||||
// 一旦超过 60 rune,说明它在**复述群聊原文** —— 那部分对排障没有价值(要的是
|
||||
// 「判定方向 + 方向词」),却正是最不该进日志的那段话。
|
||||
const engageReasonRunes = 60
|
||||
|
||||
// engageReason 把判定器回的 reason 整理成可以出镜的短句(Debug 日志与返回值共用
|
||||
// 这同一份,口径不会分叉):
|
||||
//
|
||||
// - 压平空白:reason 是模型自由文本,一个换行就能在按行聚合的日志里伪造出
|
||||
// 「另一条记录」;返回值也会流进日志,所以同样要压;
|
||||
// - 凭据清洗走 trace.RedactTextLimited(与 trace.RedactText 同一实现,不是第二套
|
||||
// 脱敏路径):模型可能把 Authorization / sk-… 之类原样回显进 reason;
|
||||
// - 截到 engageReasonRunes(见上)。
|
||||
//
|
||||
// 🔴 本函数只决定「进去的那份文本」,不参与任何判定:reason 的分支条件与返回值拼接
|
||||
// 结构一个字都不动(2026-10-26 塔口径)。
|
||||
func engageReason(raw string) string {
|
||||
return trace.RedactTextLimited(strings.Join(strings.Fields(raw), " "), engageReasonRunes)
|
||||
}
|
||||
|
||||
// DefaultEngageConfig 返回 design/18 的参数默认值(P2a 基准;P2c 会让它们
|
||||
// 可按群配置/在面板编辑)。
|
||||
func DefaultEngageConfig() EngageConfig {
|
||||
@@ -243,16 +219,16 @@ func (b *Bridge) engageProbe(ctx context.Context, msg adapter.UnifiedMessage, ac
|
||||
}
|
||||
if d.AvoidTopic {
|
||||
b.toIdle(st)
|
||||
b.log.Debug("engage probe avoid topic, staying idle", "group", key, "reason", engageReason(d.Reason))
|
||||
b.log.Debug("engage probe avoid topic, staying idle", "group", key, "reason", judgeReason(d.Reason))
|
||||
return false, "engage: avoid topic"
|
||||
}
|
||||
if d.WorthReply || d.Interesting {
|
||||
b.enterActive(st, cfg, now, msg)
|
||||
b.log.Debug("engage probing → active (respond)", "group", key, "reason", engageReason(d.Reason))
|
||||
return true, "engage: " + engageReason(d.Reason)
|
||||
b.log.Debug("engage probing → active (respond)", "group", key, "reason", judgeReason(d.Reason))
|
||||
return true, "engage: " + judgeReason(d.Reason)
|
||||
}
|
||||
b.toIdle(st)
|
||||
b.log.Debug("engage probing → idle, no interest", "group", key, "reason", engageReason(d.Reason))
|
||||
b.log.Debug("engage probing → idle, no interest", "group", key, "reason", judgeReason(d.Reason))
|
||||
return false, "engage: no interest"
|
||||
}
|
||||
|
||||
@@ -271,14 +247,14 @@ func (b *Bridge) engageFollowUp(ctx context.Context, msg adapter.UnifiedMessage,
|
||||
}
|
||||
if d.AvoidTopic || (!d.WorthReply && !d.Interesting) {
|
||||
b.countNoInterest(st)
|
||||
b.log.Debug("engage follow-up no interest / avoid", "group", key, "reason", engageReason(d.Reason))
|
||||
b.log.Debug("engage follow-up no interest / avoid", "group", key, "reason", judgeReason(d.Reason))
|
||||
return b.engageAfterFollowUp(st, cfg, now, key)
|
||||
}
|
||||
st.lastInteract = now
|
||||
st.lastTopic = contentSnippet(msg.Content)
|
||||
st.consecutiveNoInterest = 0
|
||||
b.log.Debug("engage follow-up respond", "group", key, "reason", engageReason(d.Reason))
|
||||
return true, "engage follow-up: " + engageReason(d.Reason)
|
||||
b.log.Debug("engage follow-up respond", "group", key, "reason", judgeReason(d.Reason))
|
||||
return true, "engage follow-up: " + judgeReason(d.Reason)
|
||||
}
|
||||
|
||||
// engageAfterFollowUp 判定一次无兴趣/回避跟进探测的结果。
|
||||
|
||||
Reference in new issue
Block a user