Skip to content

feat(traex): 支持额度耗尽时按模型池顺序续跑 - #2605

Merged
deepcoldy merged 4 commits into
deepcoldy:masterfrom
Cansiny0320:feat/traex-quota-fallback
Oct 31, 2026
Merged

deepcoldy merged 4 commits into
deepcoldy:masterfrom
Cansiny0320:feat/traex-quota-fallback

Conversation

@Cansiny0320

@Cansiny0320 Cansiny0320 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

改动

Closes #2604

  • 为 TraeX Auto 增加 trigger: "quota";不配置时保持原容量排队策略。
  • 仅结构化 usageLimitExceeded / usage_limit_exceeded 触发切换。普通 429、排队、网络和认证失败不触发。
  • 按配置顺序向后尝试,实时日/周额度证据可跳过已耗尽模型;全部耗尽后停止,不使用池外模型。
  • 复用 exact native resume 与原输入退休机制;继续输入继承原 turn 身份,原始输入不重放。
  • Dashboard 可选择“额度耗尽”,隐藏容量模式专用设置,保存/刷新不丢失策略。

影响面与边界

仅显式启用 quota 策略的托管 TraeX 终端。其他 CLI、旧容量策略、adopt、RPC、durable / at-most-once 保持原行为。

metadata 缺失不等于无限额度。没有 resetTime 且恢复信息持续缺失时保持停止,并提示用 /model 人工恢复。原会话续跑不代表外部工具操作具有通用 exactly-once 保证。

首次提交验证

  • bun run build:通过,包含 TypeScript、脚本与测试 mock 类型检查、Dashboard 构建和资源审计。
  • 9 个相关单测文件:504 passed,1 个既有 skipped。使用 Node 22;系统 Node 20 缺少 SQLite,不适合作为测试运行时。
  • vitest run test/traex-auto-model.integration.test.ts -t quota:5 passed;真实 Worker/PTY + 模拟 CLI,覆盖有序切换、同一 native session、原输入仅一次、全耗尽停止、普通限流不切换及初始化路径。
  • 异常探针修复:初始输入绕过 admission;确认停止后仍被迟到目录响应恢复;额度查询期间 journal 被清空;周额度可用但日额度未知时误清耗尽状态。
  • 持久化恢复守卫变异:只在内存移除守卫后,同一 journal/恢复断言由通过变为失败。

没有向真实 IM 群发送测试消息,没有创建外部业务数据,也没有人为耗尽账号额度。

界面

实际组件渲染的隔离预览:

额度耗尽策略

评审跟进验证

已按建议处理,更新提交 74e1541c4,并 rebase 到 master@42432fe84。

  1. 合并后的测试失败:先复现了 dispatch-user-route.test.ts 的 4 个 ReferenceError,再给测试 scope 注入 traexQuotaPending,增加 pending 期间 ready gate 保持关闭的用例。现在该文件 41/41 通过;移除对应守卫后,新断言会失败。
  2. 稳态查询开销:当前在池首且没有 quota block 时直接放行,不再每条输入都执行远程查询。有持久 block 或当前仍在备用模型时保留恢复查询,结构化额度失败时也仍查询。真实 Worker/PTY 记录了查询次数:原输入不查询,两次额度失败恰好查询两次;普通限流不查询、不切模型。
  3. 真实目录格式:在两台 Linux 的 TraeX 0.213.1 上执行只读 traex debug models --remote,均返回 models[].slug/business_metadata。一台提供日额度字段 internal_daily_usage.isDepleted/resetTime,另一台未提供额度信息;原始输出经过本 PR 的解析函数,分别得到明确未耗尽和 unknown,没有把缺失解释成无限额度。未持久化或发布完整目录。本次未观察到有效周额度,周额度仍只有合成测试验证。
  4. 部分窗口证据:补了日窗口已过期、周窗口仍有效的两种组合。周窗口未耗尽不能清掉日额度的已有 block;周窗口明确耗尽时保留耗尽证据。移除过期窗口完整性守卫后,对应测试会失败。
  5. 超时进程清理:改为独立 8 秒 deadline 返回 unknown 并发送 SIGTERM,1 秒后仍未退出则 SIGKILL。覆盖迟到结果不二次结算、正常结束无残余 timer、SIGTERM 后退出不再 SIGKILL。真实忽略 SIGTERM 的假 CLI 在 Node 22 / Bun 1.4.3 下均约 8 秒返回,宽限期后确认子进程已退出。

验证(Node 22.22.0 / Bun 1.4.3):

  • bun run build:通过,含 TypeScript、脚本/test mock 类型检查、Dashboard 构建和资源审计。
  • 12 个相关单测文件:452 passed、1 个既有 skipped。
  • node node_modules/vitest/vitest.mjs run test/traex-auto-model.integration.test.ts -t quota:5 passed。
  • 同文件的原容量策略、继承 RPC、关闭功能场景:3 passed;tmux 后端的 quota 续跑场景:1 passed。名称筛选以外的用例未计为通过。
  • 8 个异常探针:覆盖目录查询期间取消/改配置/队首变化、block 落盘但切换未提交的恢复、全池耗尽超时与下一输入交叠、重复失败及迟到响应,全部通过。移除 deadline 结算、首选 fast-path、过期日窗口完整性守卫或 pending ready gate 的 4 个变异均咬红。

没有向真实群发送测试消息、请求模型推理或人为耗尽额度;也没有更新或重启现有机器人。

@deepcoldy

Copy link
Copy Markdown
Owner

感谢提交!这个 PR 的评审在飞书群里进行,评审机器人和维护者会在群里讨论修改意见。加群链接:https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=4b6g2a37-29ff-41f5-afa2-241711e80f4c&qr_code=true (一年内有效)

@deepcoldy

Copy link
Copy Markdown
Owner

你好,感谢提交!这是自动评审的初步意见,最终结论以维护者审阅为准。

我已把本 PR 与最新 master(c051449ef)做了本地 rebase(无冲突),总体实现质量很好:结构化错误码判定、fail-closed 的额度证据解析、有序只进不退、exact native resume、journal 冻结与取消优先都有真实 Worker/PTY 测试覆盖。发现 1 个合并后必现的测试问题,建议处理:

P1:与最新 master 合并后 CI 会红

master 最新合入的 #2575 新增了 test/dispatch-user-route.test.ts,它会抽取 worker.ts 中 hasStructuredLifecycleBlock 的源码在手工构造的 scope 中执行。本 PR 在该函数首行新增了 if (traexQuotaPending) return true;,而该测试的 scope 没有提供这个变量,合并后会有 4 个用例因 ReferenceError: traexQuotaPending is not defined 失败(本 PR 的基线早于 #2575,所以在你当前分支上跑不出来)。

请先 rebase 到最新 master,然后给该测试的 scope 注入该变量,并可顺手补一条正向行为用例:

--- a/test/dispatch-user-route.test.ts
+++ b/test/dispatch-user-route.test.ts
@@
-function screenReady(queue: CodexBridgeQueue, cliId = 'traex') {
+function screenReady(queue: CodexBridgeQueue, cliId = 'traex', quotaPending: unknown = undefined) {
@@
     remoteRunnerRecoveredTurnInFlight: false,
+    // Quota model recovery holds terminal delivery only in traex quota pools.
+    traexQuotaPending: quotaPending,
     bareShellLaunchBlocked: false, currentInputDeliveryQuarantine: () => false,

并在 keeps the existing Codex lifecycle gate… 用例后新增:

  it('keeps the ready gate closed while a traex quota recovery lookup is pending', () => {
    const queue = new CodexBridgeQueue();
    queue.mark('om_human', 'query');
    expect(screenReady(queue)).toBe(true);
    expect(screenReady(queue, 'traex', { turnId: 'om_human' })).toBe(false);
  });

本地验证:修复后该文件 41/41 通过,且删掉 worker 中的对应守卫后新用例会变红。

两个建议(非阻断)

  1. quota 模式下目前每条独立输入提交前都会执行一次 traex debug models --remote(8s 超时)。稳态(没有任何 blocked 模型、当前就在池首)时这次远程读没有决策价值,是否可以收窄为"存在持久 block 时才读",避免每条消息都增加一次进程与远程往返,想听听你的取舍。
  2. 配额解析依赖 traex debug models --remote 的真实输出形状(slug / business_metadata 字段),CI 无法覆盖真机;如果命令或字段名有出入,证据能力会静默降级为"仅靠原生错误码有序切换"(不会误切或崩溃)。建议你在真实环境确认一次。

另外有几个小的防御性点(不阻断),评审详情在维护者群里跟进:parser 中"日窗口已过期 + 周窗口仍当前"的部分证据分支建议补一个单测;readTraexModelQuotas 超时后建议像 readTraexModelLoads 一样补 SIGTERM→SIGKILL 升级。

再次感谢,这个功能的边界(不碰普通 429/认证/网络失败、不使用池外模型、不推断跨日重置、at-most-once/adopt/RPC 不续跑)控制得很清楚。

@Cansiny0320
Cansiny0320 force-pushed the feat/traex-quota-fallback branch from 70b3b0f to 74e1541 Compare October 30, 2026 14:29
@Cansiny0320

Copy link
Copy Markdown
Contributor Author

已按建议处理,更新提交 74e1541c4,并 rebase 到 master@42432fe84。

  1. 合并后的测试失败:先复现了 dispatch-user-route.test.ts 的 4 个 ReferenceError,再给测试 scope 注入 traexQuotaPending,增加 pending 期间 ready gate 保持关闭的用例。现在该文件 41/41 通过;移除对应守卫后,新断言会失败。
  2. 稳态查询开销:当前在池首且没有 quota block 时直接放行,不再每条输入都执行远程查询。有持久 block 或当前仍在备用模型时保留恢复查询,结构化额度失败时也仍查询。真实 Worker/PTY 记录了查询次数:原输入不查询,两次额度失败恰好查询两次;普通限流不查询、不切模型。
  3. 真实目录格式:在两台 Linux 的 TraeX 0.213.1 上执行只读 traex debug models --remote,均返回 models[].slug/business_metadata。一台提供日额度字段 internal_daily_usage.isDepleted/resetTime,另一台未提供额度信息;原始输出经过本 PR 的解析函数,分别得到明确未耗尽和 unknown,没有把缺失解释成无限额度。未持久化或发布完整目录。本次未观察到有效周额度,周额度仍只有合成测试验证。
  4. 部分窗口证据:补了日窗口已过期、周窗口仍有效的两种组合。周窗口未耗尽不能清掉日额度的已有 block;周窗口明确耗尽时保留耗尽证据。移除过期窗口完整性守卫后,对应测试会失败。
  5. 超时进程清理:改为独立 8 秒 deadline 返回 unknown 并发送 SIGTERM,1 秒后仍未退出则 SIGKILL。覆盖迟到结果不二次结算、正常结束无残余 timer、SIGTERM 后退出不再 SIGKILL。真实忽略 SIGTERM 的假 CLI 在 Node 22 / Bun 1.4.3 下均约 8 秒返回,宽限期后确认子进程已退出。

验证(Node 22.22.0 / Bun 1.4.3):

  • bun run build:通过,含 TypeScript、脚本/test mock 类型检查、Dashboard 构建和资源审计。
  • 12 个相关单测文件:452 passed、1 个既有 skipped。
  • node node_modules/vitest/vitest.mjs run test/traex-auto-model.integration.test.ts -t quota:5 passed。
  • 同文件的原容量策略、继承 RPC、关闭功能场景:3 passed;tmux 后端的 quota 续跑场景:1 passed。名称筛选以外的用例未计为通过。
  • 8 个异常探针:覆盖目录查询期间取消/改配置/队首变化、block 落盘但切换未提交的恢复、全池耗尽超时与下一输入交叠、重复失败及迟到响应,全部通过。移除 deadline 结算、首选 fast-path、过期日窗口完整性守卫或 pending ready gate 的 4 个变异均咬红。

没有向真实群发送测试消息、请求模型推理或人为耗尽额度;也没有更新或重启现有机器人。

@deepcoldy

Copy link
Copy Markdown
Owner

维护者复审在最新 head 上又发现一个合并/全量测试问题(自动评审同步,最终以维护者结论为准):

P1:新 head 自身就让两个既有的 worker 源码切片测试变红(共 7 例)

这两个测试用 with(scope) 执行从 src/worker.ts 切出的真实函数,本 PR 在被切出的路径上新增了 scope 未注入的自由变量:

  • test/zcode-term-action.test.ts:handleTermAction 新增的 Ctrl-C quota 结算分支读取 traexQuotaPending,scope 未注入 → ReferenceError: traexQuotaPending is not defined,6 例红。
  • test/worker-structured-turn-attribution.test.ts:emitReadyCodexTurns 现在调用 recoverTraexQuotaTurn(turn),scope 未注入 → TypeError: recoverTraexQuotaTurn is not a function,1 例红。

我们在本 PR head 原样树上复现为 Tests 7 failed | 6 passed,而 origin/master 上这两个文件 13/13 绿。上一轮的定向验证只跑了 traex 命名的测试,没覆盖到这两个非 traex 命名的切片文件;这类失败只会在 unit 全量时暴露,请以全量 unit 为准。

处理方式:纯测试 scope 注入,src 零改动

请 rebase 到最新 origin/master(当前 887309883)后应用下面这个补丁(3 个测试文件,共 +31 行,不改任何 src):

  • 两个切片测试的手工 scope 补注入:zcode-term-action 注入 traexQuotaPending: undefined 与 emitReadyCodexTurns: vi.fn()(这些用例不是 quota 池,该分支必须惰性);worker-structured-turn-attribution 注入 recoverTraexQuotaTurn: () => false(普通结构终态不能被 quota 恢复吞掉)。这些用例原本断言的 ZCode/Pi Escape 语义保持不变,不是改成假绿。
  • 另外补一条 quota fast-path 的回归用例:维护者探针发现,把 fast-path 条件从 !hasQuotaBlocks() && currentModelIndex() === 0 改成只看 currentModelIndex() === 0 时现有用例不会红——即「首选模型停在 index 0、但带持久 block 时仍必须查询并 fail-closed,不能把输入写给已耗尽模型」这一半没有覆盖。新用例在该变异下会红。

我们已独立验证:补丁后这两个文件 13/13,traex 相关 8 文件 256 绿,并把 59 个「切片执行 worker.ts 源码」的非集成单测整类跑完 1196/1196(其中 npm-binary-distribution 需先 bun run build 产出 dist/,否则会因缺编译产物报 ENOENT,那不是本 PR 的问题)。补丁不改变任何生产逻辑。

diff --git a/test/traex-quota-worker.test.ts b/test/traex-quota-worker.test.ts
--- a/test/traex-quota-worker.test.ts
+++ b/test/traex-quota-worker.test.ts
@@ -55,6 +55,28 @@ describe('quota recovery worker boundary', () => {
     await vi.waitFor(() => expect(scope.executeTraexAutoModelSwitch).toHaveBeenCalledWith(
       expect.objectContaining({ turnId: 'next', toModel: 'first' }), { resumeCurrentTurn: false }));
   });
+  it('still queries when the preferred model is at index 0 but carries a persisted block, then fails closed', async () => {
+    const f = fixture();
+    // Restored state: pool head is still index 0, yet every model (including
+    // the current preferred one) has a persisted block without reset time.
+    const state = f.controller.runtimeState('native');
+    state.quotaBlocks = f.controller.config.models.map(model => ({ model }));
+    const blocked = new TraexAutoModelController(f.controller.config, state);
+    expect(blocked.currentModelIndex()).toBe(0);
+    expect(blocked.hasQuotaBlocks()).toBe(true);
+    const head = { turnId: 'next', content: 'new task' };
+    const scope = { ...f.scope, traexAutoModelController: blocked, pendingMessages: [head],
+      activeTurnAuthority: new ActiveTurnAuthority(), isPromptReady: true, flushPending: vi.fn(),
+      send: vi.fn(), emitTurnTerminal: vi.fn() };
+    // Must hold and read the catalog even at index 0; the fast-path only skips
+    // the read when there is no block at all.
+    expect(loadWorkerFunction('selectTraexQuotaModelBeforeTurn', scope)(head)).toBe(true);
+    expect(scope.currentTraexQuotas).toHaveBeenCalledOnce();
+    f.resolve(null); // unknown evidence never clears a persisted block
+    await vi.waitFor(() => expect(scope.emitTurnTerminal).toHaveBeenCalledWith(
+      'next', 'failed', TRAEX_QUOTA_ERROR_CODE));
+    expect(scope.executeTraexAutoModelSwitch).not.toHaveBeenCalled();
+  });
   it('keeps the attribution journal recoverable during the async quota lookup', () => {
diff --git a/test/worker-structured-turn-attribution.test.ts b/test/worker-structured-turn-attribution.test.ts
--- a/test/worker-structured-turn-attribution.test.ts
+++ b/test/worker-structured-turn-attribution.test.ts
@@ -123,6 +123,9 @@ describe('structured turn send attribution retirement', () => {
       sessionId: 'sid', bridgeGateInputForTurn: (_sid: unknown, _turn: unknown, gate: unknown) => gate,
       codexBridgeQueue: { drainEmittable: () => [extra], peek: () => [] },
       checkpointCodexAdoptRecovery: vi.fn(), checkpointStructuredBridgeRecovery: vi.fn(),
+      // Quota recovery only owns traex quota pools; these turns must be emitted
+      // as ordinary structured terminals.
+      recoverTraexQuotaTurn: () => false,
       armPostTerminalInputFence: vi.fn(), lastInitConfig: { adoptMode: false },
       isExistingAppServerSharedBridge: () => false, readSendMarkers: () => [],
       zeroPromptTerminalSync: () => false,
diff --git a/test/zcode-term-action.test.ts b/test/zcode-term-action.test.ts
--- a/test/zcode-term-action.test.ts
+++ b/test/zcode-term-action.test.ts
@@ -51,6 +51,11 @@ function harness(interruptKey?: 'esc', backendType: 'pty' | 'tmux' = 'pty', adap
     t: (key: string) => key,
     isCriticalInterruptKey,
     sendCriticalControlKey,
+    // TraeX quota recovery reads these worker globals: a quota-confirmed stop
+    // must revoke the held failure and settle it exactly once. These cases are
+    // not quota pools, so the branch must be inert.
+    traexQuotaPending: undefined,
+    emitReadyCodexTurns: vi.fn(),
     runAfterAmbiguousSubmissionWrites: async (_backend: unknown, action: () => unknown) => action(),
   };
   const factory = new Function('state', `with (state) { ${slice}; return { handleTermAction }; }`);

应用建议:

git fetch origin master
git rebase origin/master   # 887309883
git apply <上面的补丁>     # 三个文件均无冲突
bun run build
bunx vitest run --project unit test/zcode-term-action.test.ts test/worker-structured-turn-attribution.test.ts test/traex-quota-worker.test.ts

src 的功能逻辑维护者已复核无阻断;推上新 head 后我们会再确认 unit 全量(含 bun-test)在该 head 首跑全绿。另:之前提到的 recoverTraexQuotaTurn 在 generation/session 不匹配时静默 return 一点,当前路径不可达,可作为后续防御性 follow-up,不阻塞本 PR。感谢!

@Cansiny0320
Cansiny0320 force-pushed the feat/traex-quota-fallback branch from 74e1541 to de26214 Compare October 30, 2026 19:08
@Cansiny0320

Cansiny0320 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

已按本轮意见更新,提交 de262140b,并无冲突 rebase 到 master@3e6283675。

本次增量只改三个测试文件,没有改生产逻辑:

  1. zcode-term-action.test.ts 补入 traexQuotaPending 和 emitReadyCodexTurns,保留原有 ZCode / Pi、PTY / tmux 的中断行为断言。
  2. worker-structured-turn-attribution.test.ts 补入非 quota 场景的 recoverTraexQuotaTurn,原有终态和归属清理断言保持不变。
  3. traex-quota-worker.test.ts 补充首选模型停在 index 0、但带持久 block 的恢复场景:仍要查询目录;目录证据 unknown 时不得清除 block,全池不可用时返回额度失败,不切换模型。

已完成验证(Node 22.22.0 / Bun 1.4.3,macOS):

  • 本轮三个文件:33 passed,其中此前失败的两个文件 13/13 通过。
  • 扩展到 quota、controller、transcript、dispatch 等九个相关文件:311 passed、1 skipped。
  • 变异验证:临时把 fast-path 改为仅检查 currentModelIndex() === 0,新增用例立即失败;已恢复原条件,最终提交不含该变异。
  • bun run build 通过,包含 TypeScript、脚本及 test mock 类型检查、Dashboard 构建和资源审计。
  • bun run workflow-core:test 通过。

全量已经执行完,结果未全绿,没有重试整套、排除失败文件或放宽断言:

验证命令 最终结果
bun run test -- --maxWorkers=4 2098 个文件通过、31 个文件失败、34 个文件跳过;39777 项通过、62 项失败、565 项跳过;耗时约 29 分 41 秒
BOTMUX_BUN_TEST_CONCURRENCY=4 bun run test:bun 1853/1853 个可运行文件全部执行完;1812 个文件通过、41 个文件失败。另有 309 个文件按仓库既有规则交给 Vitest 执行,不计为 Bun 通过

本轮修改的三个文件均不在两套失败名单中;TraeX 自动切换集成测试也不在失败名单中。

为区分 PR 回归与基线问题,另取不含本 PR 的 master@3e6283675 原版源码,在同一环境独立对照了三组失败:

  • daemon-rename-route、aiden-codex-shim、bytedcli-identity-home、capabilities:4 failed / 191 passed,复现相同的四项失败。
  • group-join-shared-routing、tmux-pane-launch:13 failed / 58 passed / 2 skipped,复现相同的十三项失败。
  • worker-agy-full-transcript、worker-grok-startup-trust、worker-first-prompt-hard-cap、worker-pi-sandbox-session-dir、worker-pi-transcript-cwd-move:8 failed / 2 passed / 3 skipped,复现相同的八项失败。

其余失败尚未逐项完成上游对照,不统一归因为上游问题。日志中另有明确的平台差异,例如 macOS 不支持 GNU find -printf / head -n -2、tmux socket 临时路径过长,以及 /var 与 /private/var 的路径断言差异。这些问题没有混入本次三个测试文件的修复;目前不能声称全量通过,仍需 Linux CI / 维护者环境确认。

本轮没有更新或重启真实机器人,也未向真实群发送测试消息。

@Cansiny0320

Copy link
Copy Markdown
Contributor Author

补充运行时修复,已推送 c14c12e23。前两轮评审要求的测试 scope 和持久 block 回归用例均保留。

本次修复

TraeX quota 模式首条输入采用延后投递。原 fast-path 直接返回,没有向 controller 登记当前待投递 turn;若 flushPending 清掉 prompt-ready 后遇到异步 viewport revision 变化而暂缓,重试会被 readiness gate 永久挡住:CLI 已启动,但用户输入没有写入 PTY。

现在在 fast-path 放行时调用 beginTurn(turnId, { retainCurrentModel: true }),仅登记该待投递 turn,不提前标记已提交、不切换模型、不增加额度目录查询。仍有持久 block 的分支保持 fail-closed。改动限于 TraeX auto-model quota 路径,没有修改其它 CLI 的准入策略。

新增回归测试覆盖无 native session ID 和已有 native session ID 两种状态:首次放行 → readiness 清零 → viewport 变化暂缓 → 没有新 idle 事件仍能重试同一 turn;提交后,下一 turn 不能复用陈旧 composer 放行。修复前两例失败,修复后通过。另验证取消、关闭 controller、generation 变化和队首替换会拒绝陈旧重试;移除新增登记动作可再次复现卡住。

已完成验证

  • Node 22 的 7 个关联测试文件:259 passed。
  • Bun 1.4.3:traex-auto-model-worker 113 passed,traex-quota-worker 20 passed。
  • node node_modules/vitest/vitest.mjs run test/traex-auto-model.integration.test.ts -t quota:真实 Worker/PTY 5 passed;tmux 后端同组 5 passed。筛选之外的用例未计入通过。
  • bun run build:通过,包含类型检查、Dashboard 构建与资源审计。
  • Fork 发布分支构建的 Linux 独立二进制:5 项 Worker/tmux quota 故障注入通过;两台 Linux 的隔离 binary smoke 均通过,包含 Canvas PNG、插件生命周期、supervisor/dashboard/HTTP 和完整性检查。
  • 已将 Fork v3.55.5-canary.1 部署到两台 Linux,校验运行中 daemon/worker 均来自新二进制,配置与备份逐字一致。
  • 两台分别通过新部署的 Botmux headless 会话调用真实 TraeX / GPT-6.1-Sol,处理本地合成卡片:固定代码认领,Agent 自主执行后续三次操作,每步回读,最终卡片 complete=true,并生成结论文件和正常的 completed 终态。复用实际卡片执行脚本,但消息传输/回调为隔离模拟;没有向真实群发送测试报警、操作真实卡片或创建真实缺陷。此项不是生产 IM 入口和真实卡片传输的全链路验收,也不是人为耗尽真实额度的测试。

本次增量未重跑两套全量测试,因此不宣称新 head 全量全绿。上一 head de262140b 的四个 unit shard、bun-test、build、Linux binary 检查已通过;当时 Darwin binary job 的失败注释为 GitHub macOS 14 runner 计划 brownout,没有将无关 runner 迁移混入此 PR。

@deepcoldy
deepcoldy merged commit d6c1d90 into deepcoldy:master Oct 31, 2026
11 checks passed
@deepcoldy

Copy link
Copy Markdown
Owner

已合并,感谢贡献!🎉

squash 落地提交 d6c1d90,保留你的作者署名;落地树与合并预测树逐字一致。

这个功能的边界控制得很到位:只认结构化的 usageLimitExceeded / usage_limit_exceeded、不把普通 429/排队/网络/认证失败当额度耗尽、只在配置池内向后切换不循环、不使用池外模型、不推断跨日重置、adopt/RPC/durable/at-most-once 不自动续跑;中途根据评审补的几轮也很扎实(worker 源码切片测试的 scope 注入、catalog reader 的 SIGTERM→SIGKILL、过期日窗口/周窗口的部分证据用例、fast-path 的 block 回归,以及最后"首条输入暂缓后无法重试"的修复都带了能咬红的测试)。

遗留一个非阻塞的防御性 follow-up(不影响本次合并,可另开 PR):

  • src/worker.ts 中 recoverTraexQuotaTurn 的异步回调在 cliSpawnGeneration / cliSessionId / active authority 不匹配时是静默 return。当前同进程会话轮换不会改写 cliSessionId、跨进程重启有 journal 兜底,所以该分支实际不可达;但作为防御性改进,可考虑在那里 fail-open 结算原始失败终态(而不是既不切换也不结算),成本很低。

另:仓库的 macOS 14 runner 将于 2026-11-02 退役(brownout 已开始),CI/发布链路迁 macos-15 由我们在 #2628 跟踪,与本 PR 无关。

再次感谢,欢迎继续贡献!

deepcoldy pushed a commit that referenced this pull request Oct 31, 2026
同步最新 master(#2585 回复页脚控制台入口、#2605 TraeX 额度池顺序续跑、
#2630、#2619、#2473、#2568 共 6 提交)。与本 PR 仅在四个 i18n/页面文件
交集(bot-defaults-page.tsx、dashboard/web/i18n.ts、i18n zh/en),均为
各自新增不同键的同段并存,git 自动合并无冲突:本 PR 的 sharedSandbox* /
sandbox_advice.* 全套与 master 的 replyFooter / autoModelQuota* 键共存。

Co-Authored-By: Claude Code <[email protected]>
@github-actions

Copy link
Copy Markdown

@Cansiny0320 @deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。

这次运行覆盖 d6c1d90…0932a460d(4 个提交),同批合入的还有 #2623 #2633 #2624,失败不一定由本 PR 引起。

用例 跑道 状态 失败信息
Gemini basic bot flow feishu-core-clis failed waitFor timeout: Based on the screenshot, the main content area displays a conversation thread titled "话题" (Topic). I am examining the messages from "Gemini".

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

🚀 Released in v3.56.0

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.

feat(traex): 支持额度耗尽时按模型池顺序切换并续接原会话

2 participants