Skip to content

Commit 409db14

Browse files
bot-talk-kclaude
andcommitted
fix: 健康度给"用户 24h 内回过"豁免,避免低流量通道被持续判黄
channel 9 场景:用户 5h 前回复过(context_token 刚刷新),只是 5h 无 成功推送 → 旧逻辑判黄"329 分钟未推送成功"。实际上 context_token 健康, 只是没人推而已,不应示警。 新规则: - 绿 = poller 活 + 无最近 ret:-2 + (4h 内成功推 OR 24h 内用户回复) - 黄条件加 !inboundFresh 前置:只有在用户也长时间未回复时才判黄 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fa38bec commit 409db14

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

services/channel-health.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,17 @@ function getChannelHealth(channel) {
9292
if (neg2Count > 0 && lastNeg2 !== null && lastNeg2 < 60 * 60 * 1000) {
9393
return { health: 'yellow', reason: `最近 ${Math.round(lastNeg2/60000)} 分钟内出现 ${neg2Count} 次 ret:-2`, details };
9494
}
95-
if (lastSendOk !== null && lastSendOk > 4 * 60 * 60 * 1000) {
96-
return { health: 'yellow', reason: `${Math.round(lastSendOk/60000)} 分钟未推送成功(poller 仍活)`, details };
95+
// "长时间无成功推送"判黄之前,先给"用户最近回复过"一个豁免:
96+
// 用户回复会刷新 context_token,24h 内回过就不算异常(低流量用户不应被持续判黄)
97+
const inboundFresh = lastInbound !== null && lastInbound < 24 * 60 * 60 * 1000;
98+
if (lastSendOk !== null && lastSendOk > 4 * 60 * 60 * 1000 && !inboundFresh) {
99+
return { health: 'yellow', reason: `${Math.round(lastSendOk/60000)} 分钟未推送成功,用户也长时间未回复`, details };
97100
}
98-
if (lastSendOk === null && dbStatus === 'active') {
99-
return { health: 'yellow', reason: '通道激活后尚无成功推送记录', details };
101+
if (lastSendOk === null && dbStatus === 'active' && !inboundFresh) {
102+
return { health: 'yellow', reason: '通道激活后尚无成功推送记录,用户也未回复过', details };
100103
}
101104

102-
// 绿:poller 活 + 近期(4h 内)有成功推送 + 无最近 ret:-2
105+
// 绿:(4h 内成功推送 OR 24h 内用户回复过) + poller 活 + 无最近 ret:-2
103106
return { health: 'green', reason: '正常', details };
104107
}
105108

0 commit comments

Comments
 (0)