feat(worker): 会话上限改按 bot 配 + 默认不限,删 worker-budget skill/CLI#231
Open
deepcoldy wants to merge 1 commit into
Open
feat(worker): 会话上限改按 bot 配 + 默认不限,删 worker-budget skill/CLI#231deepcoldy wants to merge 1 commit into
deepcoldy wants to merge 1 commit into
Conversation
需求(申晗): worker-budget 不该当 skill(污染 agent 上下文+撑 --help token), 改成 dashboard 每个 bot 一个「最大活跃会话数」配置项;默认不设上限(资源够用 时老会话永不休眠,体验最佳),去掉时间超时维度,只按会话数封顶,超过后最久未用 的会话转休眠(下条消息/打开终端唤醒)。 - 删 botmux-worker-budget skill(进 RETIRED_SKILL_NAMES,升级时自动从各 CLI skills 目录清掉) + 删 botmux worker-budget CLI 子命令(含 --help/dispatch) - 删 core/worker-budget.ts(自动推导/idleSuspendMs 全去) + 全局 worker config 块 - BotConfig 加 maxLiveWorkers(per-bot,bots.json);parseBotConfigsFromText 只认正整数 - idle-worker-sweeper 改纯按数封顶: 无 cap→no-op;超 cap 时按 lastMessageAt 把 最久未用的非 adopt/可恢复后端/非忙(屏幕 idle)会话休眠到 cap 内,无 idle 时间门 (只保留'不打断正在出答案的会话'的正确性守卫)。daemon 每分钟读实时 bot.config 免重启生效 - bot-config-store 新增 'number' 字段 kind(coerce 校验正整数) + 注册 maxLiveWorkers - dashboard: 群组与机器人卡片加「会话数上限」section + /api/bots(/:appId)/ max-live-workers PUT 通道(经 applyConfigField 落盘+内存热更) + zh/en i18n - 测试: 重写 idle-worker-sweeper(8 例,覆盖无 cap/纯计数无时间门/pty/忙/adopt) + bot-config-store number kind + bot-registry parse + builtin-skills 退役断言; 删 worker-budget*/global-config-worker 测试
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.
背景
申晗指出
botmux-worker-budget不该当 skill——既污染每个 agent 会话的上下文(描述常驻),非 skill 注入的 CLI(如 GPT)还会靠--help读到它撑大 token。需求收窄为:底层「超阈值→暂停最久未用 worker→下条消息 forkWorker 唤醒」机制本就存在(idle-worker-sweeper),本 PR 是把它从全局自动预算改成 per-bot 纯计数封顶,并把入口从 skill/CLI 挪到 dashboard。
改动
botmux-worker-budget移出BUILTIN_SKILLS,加进RETIRED_SKILL_NAMES→ installer 下次 spawn 时自动从各 CLI skills 目录清掉旧目录。botmux worker-budget子命令(jsdoc/help/实现/dispatch 全删)→ 减--helptoken。core/worker-budget.ts(CPU×2/内存推导、idleSuspendMs、30min 门)+ 全局workerconfig 块。默认 = 无上限。BotConfig.maxLiveWorkers(写 bots.json,parseBotConfigsFromText只认正整数,≤0/小数/非数→undefined=不限)。lastMessageAt把最久未用的 非 adopt + 可恢复后端(tmux/herdr/zellij) + 非忙(屏幕 idle) 会话休眠到 cap 内。无 idle 时间门——只保留「不打断正在出答案的会话」这个正确性守卫;若超额会话恰好都在忙,本轮不动等下轮。daemon 每分钟读实时bot.config.maxLiveWorkers,dashboard 改完免重启 60s 内生效。PUT /api/bots/:appId/max-live-workers→ 经applyConfigField(新增'number'字段 kind,coerce 校验正整数)落盘 + 内存热更;zh/en i18n。物理事实(已在 UI 帮助文案中说明)
测试
idle-worker-sweeper.test.ts(8 例:无 cap/无 idle 时间门的纯计数/pty 不暂停/忙时不暂停/adopt 守卫)。bot-config-store.test.ts加'number'kind round-trip + coerce 校验;bot-registry.test.ts加maxLiveWorkers解析;builtin-skills.test.ts改成退役断言。worker-budget*/global-config-worker测试。pnpm build0 error;全量单测 4524 passed。未发版、未部署。