Repository navigation
fix(minimax-bot): 群纪要的三处收尾,与后台任务也计入用量台账 - #87
Merged
MyPrototypeWhat merged 1 commit intoOct 27, 2026
Merged
Conversation
Contributor
Author
|
真模型那层刚在 mcode 上跑过一遍,没问题,结果补在正文里那段了。这次只跑了一个后台任务,多个后台任务串起来的情况未验证。 |
MyPrototypeWhat
approved these changes
Oct 27, 2026
MyPrototypeWhat
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed at 9d2d5cd. This carries over the three fixes from #86 and adds metering for background jobs. Approving.
What I verified
- The three #86 fixes are unchanged. Compared with #86's head
7c2fd89, the only differences are inengine.mjs(the new metering), the README and the newtests/helper-usage.test.mjs.tailOf, theminimax-bot-tag matching, the server-providednoteLimitsand their tests are byte-for-byte what I checked in #86. - A background job's own turn is now written to the usage ledger once.
runHelperappends one row withkind: 'helper-run'after the run settles, carrying the duration of theagent.runcall, the number oftool.startedevents and the length of the reply text. Status maps as described:failedbecomeserror;stoppedandinterrupted(including a stop or a restart) becomeaborted; everything else, includingblocked, isdone. - No double counting. Before this PR the job's own turn never reached the ledger; only the follow-up turn that relays the report to the Bot did (through
runBotTurn,kind: 'helper'). That relay is a separate model turn and is still recorded once, as before. So one job now shows as two rows because the model really ran two turns. Thehelper-runrow is written only whenagent.runwas actually called: a job stopped while still waiting for a slot writes nothing. - The usage panel. The panel's totals, per-Bot and per-bucket counts don't filter by
kind, so ahelper-runrow counts as one turn with its chars, tools and duration, and anerrorrow counts in the error total, like any other turn. The per-chat summary useshelper.chatId, so the job is attributed to the chat that started it. The turn count goes up by exactly the number of background jobs that ran, which is the intent stated in the README. - Scope. The new write goes to the existing
usage.jsonlinside the Mini App'sdataDirthrough the same queuedrecordUsageas every other turn, and the README's data section says so. No new files, permissions or network access. - Version. 0.7.12 is consistent across
plugin.json,package.jsonand the MCPserverInfo(main is at 0.7.11), and the 0.7.12 README section now also describes the background job metering.
Checks run
npx -y -p node@22 npm run checkat 9d2d5cd: passes.- Plugin suite, run inside
plugins/minimax-ai/minimax-botwithnode --test tests/*.test.mjs(Node 22, jsdom and ajv installed locally): 266 tests, 262 pass, 4 fail. The same 4 tests fail on currentmainin the same environment (one reactions-on-final-bubble test and three emoji picker tests), so this PR didn't cause them. The newhelper-usagetests and all the group note, relay guard and panel tests pass.
Optional
- A job that ends
blocked(it asked a question and was handed back to its Bot) is recorded asdone. That matches how a normal turn with a pending question is treated, so it's fine. I'm only mentioning it in case you want a separate status later. - The panel doesn't distinguish a background job's turn from the turn that relays its report. If you want users to see where turns went, the
kindis already in the ledger and could be broken out in the panel. - Still open from #86, and still fine as is: a tag with a zero-width character inside the name, or with more than 40 characters of attribute text, is not matched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
上一条 PR(#80)合进去以后,评审里提的三点我都改了。其中一条是我自己写出来的问题:裁一条记录的时候,原来会一直裁到第一个空格,而中文没有空格,于是中文的记录可能只剩最后几个字。现在只在切口正好落在英文单词中间的时候,才把那半截词去掉,而且最多去掉 20 个字符——中文在两个汉字之间切开本来就是边界,一个字都不会丢。中文和中英混排的用例都补上了。
协议标记原来只认写死的那么几个,现在认的是任意一个 minimax-bot- 开头的标签:带空格、带属性、大小写不同,或者用了一个长得像短横的字符,都会被去掉。去掉的时候只动标签本身,前后的文字留着,中文的标点也不会被改写——这里没有对全文做 NFKC,因为那会把中文的逗号变成半角,改成只折叠那些可能冒充短横和 ASCII 字母的字符,一个字符对一个字符,位置才对得上。
面板提示里原来写死了 6 条 / 1200 字,现在这两个数由服务端随状态一起下发,面板照着写,限额变了提示也跟着变。
另外还发现一处:后台任务是模型实打实跑的一回合,同一个模型、同一套工具、同样花时间,但这一回合从来没进过用量台账——台账里只留着把报告转述回来的那一回合,面板上显示的回合数于是比模型实际跑的少,后台任务越多,差得越多。
改法是在 runHelper 里量自己这一回合的耗时、工具次数和产出,跑完照 Bot 那一回合的样子写一行台账,kind 记成 helper-run;失败的记成 error,被停掉或被中断的记成 aborted。面板那边不用动,它本来就是按台账行数统计的,以前只是少了这些行。
官方 README 自己写着 every Bot reply, scheduled task and background job is an Agent turn,台账漏掉的正是这一类回合,所以这条得补上。拿一条 6 环的后台任务链量了量,每一环都是后台任务跑完、Bot 复核的时候再起下一个:上游 0.7.11 那边模型实际调用 13 次,台账只有 7 行,差的 6 行全是后台任务自己那一回合;改完之后同一条链,台账 13 行。真模型上也量了一遍:让 Chief 起一个后台任务去查仓库,宿主日志里是 3 次模型调用(27 秒、103 秒、14 秒),台账同样 3 行,差 0;后台任务自己那回合的 103 秒和 13 次工具调用,都记在它自己那一行里。
新补的测试里,模型调用几次台账就得有几行;后台任务失败记成 error;被停掉的记成 aborted,而且它不会再转述,所以也就没有第三行;面板上回合那一栏要等于模型实际调用次数。这四条在没改过的上游代码上都是红的。
上游 npm run check 的两半都在本地跑了,scripts/validate.mjs 对本插件报 minimax-bot: OK 和 repository: OK,根目录 87/87 条测试;插件自带套件 266 过、0 挂,比上游 main 多 9 条——中文条目、中英混排、标记的几种写法、中文不被改写、面板照着服务端的数写各一条,加上上面那四条。