feat(aichat): force cut multi calls

This commit is contained in:
源文雨 2026-01-06 23:16:41 +08:00
parent ae165349b9
commit 36397fb583

View File

@ -110,6 +110,8 @@ func init() {
ctx.NoTimeout() ctx.NoTimeout()
logrus.Debugln("[aichat] agent set no timeout") logrus.Debugln("[aichat] agent set no timeout")
hasresp := false hasresp := false
ispuremsg := false
hassavemem := false
for i := 0; i < 8; i++ { // 最大运行 8 轮因为问答上下文只有 16 for i := 0; i < 8; i++ { // 最大运行 8 轮因为问答上下文只有 16
reqs := chat.CallAgent(ag, zero.SuperUserPermission(ctx), i+1, x, mod, gid, role) reqs := chat.CallAgent(ag, zero.SuperUserPermission(ctx), i+1, x, mod, gid, role)
if len(reqs) == 0 { if len(reqs) == 0 {
@ -117,10 +119,35 @@ func init() {
break break
} }
hasresp = true hasresp = true
haseoa := false
for _, req := range reqs { for _, req := range reqs {
if req.Action == goba.SVM { // is a fake action if req.Action == goba.SVM { // is a fake action
if hassavemem {
if !haseoa {
ag.AddTerminus(gid)
haseoa = true
logrus.Warnln("[aichat] agent call save mem multi times, force inserting EOA")
} else {
logrus.Warnln("[aichat] agent call save mem multi times, but EOA has been inserted")
}
break
}
hassavemem = true
continue continue
} }
if req.Action == "send_private_msg" || req.Action == "send_group_msg" {
if ispuremsg {
if !haseoa {
ag.AddTerminus(gid)
haseoa = true
logrus.Warnln("[aichat] agent call send msg multi times, force inserting EOA")
} else {
logrus.Warnln("[aichat] agent call send msg multi times, but EOA has been inserted")
}
break
}
ispuremsg = true
}
_ = ctx.CallAction(req.Action, req.Params) _ = ctx.CallAction(req.Action, req.Params)
} }
} }