agentV2 点击停止后经常无法停止
Maintainers usually reply within 1 day
@c121914yu is already working on this.
Since Sep 9, 2026.
Assessment
This issue has not been assessed yet.
Description
4.16.0
agentV2 点击停止后经常无法停止,F12 STOP如下:
有时可以停止,F12 STOP如下
分析
Redis 标志删除与 MongoDB 状态更新的竞态
时序问题:
工作流的 finally 块(dispatch/index.ts:388)先删除 Redis 停止标志
Stop API 的 waitForWorkflowComplete 检测到标志删除,立即读取 MongoDB 的 chatGenerateStatus
但 updateChatGenerateStatus 或 finalizeChatRound 是在工作流返回到 v2/chat/completions.ts:453 之后才调用的
此时 MongoDB 中的状态仍然是 generating (0),还没被更新为 done (1)
关键代码路径:
dispatch/index.ts finally 块:
→ delAgentRuntimeStopSign() // 删除 Redis 标志
v2/chat/completions.ts:
→ await dispatchWorkFlow() // 等待工作流返回
→ ... 后续处理 ...
→ updateChatGenerateStatus({ status: done }) // 更新 MongoDB 状态(在 Redis 删除之后!)
Stop API 在 Redis 标志删除后立即读取 MongoDB,但此时 chatGenerateStatus 还没更新,所以返回 completed: false。
工具执行阶段不检查停止信号
Agent Loop 的停止检查点:
LLM 流式输出时(stream.ts:44,128,202):每个 chunk 都检查 isAborted?.(),能快速响应
工具执行返回后(base.ts:651,679,685):只在工具完成后检查
循环迭代之间(base.ts:685):每轮 LLM 调用后检查
问题: 当 Agent 调用工具(如 HTTP 请求、沙盒执行、子应用、知识库搜索)时,工具执行期间不检查停止信号。如果工具执行时间 > 5 秒:
Stop API 超时返回 completed: false
工作流继续运行直到工具完成
用户看到"停止失败"
代码证据(base.ts:532):
const { response, ... } = await onRunTool({ // 这里 await 工具完成,期间不检查 stop
call: tool,
messages: cloneRequestMessages,
assistantMessage: llmAssistantMessage
});
Stop API 超时返回 completed: false
工作流继续运行直到工具完成
用户看到"停止失败"
代码证据(base.ts:532):
const { response, ... } = await onRunTool({ // 这里 await 工具完成,期间不检查 stop
call: tool,
messages: cloneRequestMessages,
assistantMessage: llmAssistantMessage
});
- Dominant language
- TypeScript
- Stars
- 29.9k
- Forks
- 7.3k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 211
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from labring/FastGPT
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
labring/FastGPT#8141 · 1 comment ·
Maintainers usually reply within 1 day
-
工具调用节点落库的 AI 消息 dataId 与 responseChatItemId 不一致,getResData 按后者查询返回为空Possibly taken @c121914yu claimed this 7 days ago. Openbug
labring/FastGPT#8134 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
fastgpt的cpu资源占用非常高Openbug undetermined
Difficulty 4/5 3-5 days Newbie friendliness 35/100
labring/FastGPT#8012 · 1 comment ·
Maintainers usually reply within 1 day
-
4.17.2画布拖动有bugPossibly taken @Nixieboluo claimed this 21 days ago. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
labring/FastGPT#7948 · 1 assignee ·
Maintainers usually reply within 1 day
-
功能请求:知识库训练支持定时执行窗口与队列限速May be free again @XY-code1 claimed this 9 days ago, and no pull request is open. Openundetermined
Difficulty 5/5 Over a week Newbie friendliness 35/100
labring/FastGPT#7880 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JuliusBrussee/caveman#1449 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
linagora/twake-calendar-frontend#1924 ·
Maintainers usually reply within 1 day
-
Add: Class TV ModaOpencheck:passed streams:add
Difficulty 1/5 Under an hour Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
libnativeapi/nativeapi#21 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
GiganticMinecraft/seichi-playguide#183 ·
Maintainers usually reply within 1 day