Skip to content

fix(minimax-bot): 取消父任务时关闭子批次,不再永久泄漏 - #188

Open
Apageoflove wants to merge 1 commit into
MiniMax-AI:mainfrom
Apageoflove:fix/cancel-child-batch
Open

Apageoflove wants to merge 1 commit into
MiniMax-AI:mainfrom
Apageoflove:fix/cancel-child-batch

Conversation

@Apageoflove

@Apageoflove Apageoflove commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

父任务可以等一个子批次。取消父任务时,子任务也被取消了,但子批次自己的通知状态还停在 pending。pending 的批次算活跃批次,所以它永远不会被裁掉 —— 每取消一次委派,状态文件里就多留一个活批次。

还有一个原因让它永远裁不掉:父任务对这个子批次的依赖也停在未消费状态。父任务已经被取消,不会再消费它,而 batchActive() 会把“父任务还欠着这个依赖”的批次算作活跃。

实测 40 次取消之后:

live taskBatches in state.json = 70
archived records                 = 10
batches stuck in notification=pending = 40
get_tasks: notification = pending | complete = true

也就是 complete=true 却又 notification=pending,自相矛盾。释放占用的聊天再等 2 秒,40 个批次还是活跃的,不会自己收口。

改了两处。取消依赖时,让子批次走已有的投递收口路径;那条路径本来就会把“父任务已取消”的批次标成 posted。同时把这个依赖标为已消费 —— 取消已经回答了它,不再欠着。这样 batchActive() 的两个判据都能正常结束,批次可以按原有规则归档。

同一个 40 轮探针,改后是:

live taskBatches in state.json = 30
archived records                 = 50
batches stuck in notification=pending = 0
get_tasks: notification = posted | complete = true

测试加了三条:父任务取消后子批次不再 pending 且不再活跃;查询不再自相矛盾;状态文件里不会留下“通知还是 pending、任务却已全部结算”的批次。三条在未改的 main 上都是红的,失败点都是等不到子批次关闭。全量 443 条过。

版本号 0.7.44。当前 main 是 0.7.40;前面还有 #184(0.7.41)、#172(0.7.42)、#187(0.7.43),按这个顺序合。

验证范围:只有 Node 22 上的测试是实测的。真实 Host 和 Electron 我没跑过 —— 这一层是仅个人判断。


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

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.

1 participant