Skip to content

Commit 36397fb

Browse files
committed
feat(aichat): force cut multi calls
1 parent ae16534 commit 36397fb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

plugin/aichat/main.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,44 @@ func init() {
110110
ctx.NoTimeout()
111111
logrus.Debugln("[aichat] agent set no timeout")
112112
hasresp := false
113+
ispuremsg := false
114+
hassavemem := false
113115
for i := 0; i < 8; i++ { // 最大运行 8 轮因为问答上下文只有 16
114116
reqs := chat.CallAgent(ag, zero.SuperUserPermission(ctx), i+1, x, mod, gid, role)
115117
if len(reqs) == 0 {
116118
logrus.Debugln("[aichat] agent call got empty response")
117119
break
118120
}
119121
hasresp = true
122+
haseoa := false
120123
for _, req := range reqs {
121124
if req.Action == goba.SVM { // is a fake action
125+
if hassavemem {
126+
if !haseoa {
127+
ag.AddTerminus(gid)
128+
haseoa = true
129+
logrus.Warnln("[aichat] agent call save mem multi times, force inserting EOA")
130+
} else {
131+
logrus.Warnln("[aichat] agent call save mem multi times, but EOA has been inserted")
132+
}
133+
break
134+
}
135+
hassavemem = true
122136
continue
123137
}
138+
if req.Action == "send_private_msg" || req.Action == "send_group_msg" {
139+
if ispuremsg {
140+
if !haseoa {
141+
ag.AddTerminus(gid)
142+
haseoa = true
143+
logrus.Warnln("[aichat] agent call send msg multi times, force inserting EOA")
144+
} else {
145+
logrus.Warnln("[aichat] agent call send msg multi times, but EOA has been inserted")
146+
}
147+
break
148+
}
149+
ispuremsg = true
150+
}
124151
_ = ctx.CallAction(req.Action, req.Params)
125152
}
126153
}

0 commit comments

Comments
 (0)