mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-17 23:57:30 +08:00
improve autonomy conversation tone with high-value proactive notifications
This commit is contained in:
@@ -385,13 +385,16 @@ func (e *Engine) dispatchTask(st *taskState) {
|
|||||||
func (e *Engine) sendCompletionNotification(st *taskState) {
|
func (e *Engine) sendCompletionNotification(st *taskState) {
|
||||||
e.writeReflectLog("complete", st, "task marked completed")
|
e.writeReflectLog("complete", st, "task marked completed")
|
||||||
e.writeTriggerAudit("complete", st, "")
|
e.writeTriggerAudit("complete", st, "")
|
||||||
|
if !isHighValueCompletion(st) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if !e.shouldNotify("done:" + st.ID) {
|
if !e.shouldNotify("done:" + st.ID) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.bus.PublishOutbound(bus.OutboundMessage{
|
e.bus.PublishOutbound(bus.OutboundMessage{
|
||||||
Channel: e.opts.DefaultNotifyChannel,
|
Channel: e.opts.DefaultNotifyChannel,
|
||||||
ChatID: e.opts.DefaultNotifyChatID,
|
ChatID: e.opts.DefaultNotifyChatID,
|
||||||
Content: fmt.Sprintf("[Autonomy] Task completed: %s", st.Content),
|
Content: fmt.Sprintf("✅ 已完成:%s\n下一步:如需我继续处理后续,直接回复“继续 %s”", shortTask(st.Content), shortTask(st.Content)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,7 +407,7 @@ func (e *Engine) sendFailureNotification(st *taskState, reason string) {
|
|||||||
e.bus.PublishOutbound(bus.OutboundMessage{
|
e.bus.PublishOutbound(bus.OutboundMessage{
|
||||||
Channel: e.opts.DefaultNotifyChannel,
|
Channel: e.opts.DefaultNotifyChannel,
|
||||||
ChatID: e.opts.DefaultNotifyChatID,
|
ChatID: e.opts.DefaultNotifyChatID,
|
||||||
Content: fmt.Sprintf("[Autonomy] Task blocked: %s (%s)", st.Content, reason),
|
Content: fmt.Sprintf("⚠️ 任务受阻:%s\n原因:%s\n建议:回复“继续 %s”我会按当前状态重试。", shortTask(st.Content), strings.TrimSpace(reason), shortTask(st.Content)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,6 +754,33 @@ func min(a, b int) int {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isHighValueCompletion(st *taskState) bool {
|
||||||
|
if st == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if priorityWeight(st.Priority) >= 3 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(st.DueAt) != "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
s := strings.ToLower(strings.TrimSpace(st.Content))
|
||||||
|
for _, k := range []string{"urgent", "重要", "付款", "payment", "上线", "release", "deadline", "截止"} {
|
||||||
|
if strings.Contains(s, k) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func shortTask(s string) string {
|
||||||
|
s = strings.TrimSpace(s)
|
||||||
|
if len(s) <= 32 {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
return s[:32] + "..."
|
||||||
|
}
|
||||||
|
|
||||||
func hashID(s string) string {
|
func hashID(s string) string {
|
||||||
sum := sha1.Sum([]byte(strings.ToLower(strings.TrimSpace(s))))
|
sum := sha1.Sum([]byte(strings.ToLower(strings.TrimSpace(s))))
|
||||||
return hex.EncodeToString(sum[:])[:12]
|
return hex.EncodeToString(sum[:])[:12]
|
||||||
|
|||||||
Reference in New Issue
Block a user