Skip to content

fix(minimax-bot): 排队中的后台任务能停掉了 - #146

Merged
MyPrototypeWhat merged 1 commit into
MiniMax-AI:mainfrom
Apageoflove:fix/minimax-bot-stop-queued
Nov 20, 2026
Merged

MyPrototypeWhat merged 1 commit into
MiniMax-AI:mainfrom
Apageoflove:fix/minimax-bot-stop-queued

Conversation

@Apageoflove

@Apageoflove Apageoflove commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

后台任务的停止按钮,对还在排队的任务按下去没有用。

panels.js 里那个 active 集合包含 queued,所以任务一创建、还没开始跑的时候,面板上就有停止按钮。可 stopHelper 是先到 helperRuns 里找一个 run 对象,找到才 abort。run 要等 runHelper 真正启动时才注册进去。所以在排队那段窗口里按停止,stopHelper 走 !run 那条分支返回 stopped:false,不报错、不改状态、不留任何标记。等 save 完成,runHelper 照常启动,任务跑完,状态变成 done。

我拿同一个脚本打两边,差别很直接:

基线 0.7.28   后台回合跑了 2 次   helper 最终状态 done
改完之后      后台回合跑了 0 次   helper 最终状态 stopped

基线那 2 次不是笔误,runHelper 里把 status 直接赋成 running,所以一个已经被标停的任务也会被拉起来跑完。

仓库里本来就有一条测试叫 a helper cancelled while its admission is persisted is marked stopped and never runs,看着像是覆盖了这个场景。它测的是 cancelChat,走的是 startHelper 里 isActiveTurn 那条路,turn 被取消了所以标停。但用户自己点停止的时候 turn 是活的,isActiveTurn 为真,根本走不到那一步。所以那条测试一直在过,缺陷一直在。

改法是两处。stopHelper 在找不到 run 时,如果这个 helper 还是 queued,就直接把它标成 stopped、写 endedAt、存盘、广播,返回 stopped: true。runHelper 开头加一句,status 已经是 stopped 就直接返回,不建 run 也不跑回合。

已经跑起来的任务不受影响,还是 abort 那个 controller。

测试加在 engine-reliability 里:把准入那次 save 卡住,等 helper 进了列表但 helperRuns 里还没有,这时调 stopHelper,放开 save,断言它停在 stopped 且没有多跑一个后台回合。这条在 0.7.28 上红,在切片上绿。全量 414 条过。

版本号到 0.7.32。0.7.29 到 0.7.31 被另外三条还开着的 PR 占着。

batch 型任务的停止按钮是另一条路径,走 /api/tasks/:id/stop,这次没动。它和 helper 用的是不同的队列,我没细看那边有没有同样的问题。


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@Apageoflove
Apageoflove force-pushed the fix/minimax-bot-stop-queued branch 2 times, most recently from f08d09e to c8fe487 Compare November 20, 2026 01:16
后台任务面板对 queued 也画停止按钮,但 stopHelper 只 abort helperRuns 里的
run 对象,而 run 要等 runHelper 启动时才注册。所以在排队窗口里按停止,
stopHelper 走 !run 分支返回 stopped:false,不报错、不改状态、不留标记;
save 完成后 runHelper 照常启动,任务跑完并把状态写成 done。

改成 stopHelper 找不到 run 时,若 helper 还是 queued 就标成 stopped、写
endedAt、存盘、广播;runHelper 开头加守卫,status 已是 stopped 就直接返回。

同一脚本对照:基线后台回合跑 2 次、状态 done;改完 0 次、状态 stopped。
新测试在 0.7.28 上红、在切片上绿。全量 414 条通过。
@Apageoflove
Apageoflove force-pushed the fix/minimax-bot-stop-queued branch from c8fe487 to 52a75d2 Compare November 20, 2026 06:20
@MyPrototypeWhat
MyPrototypeWhat merged commit 0e8c24a into MiniMax-AI:main Nov 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants