Repository navigation
feat(traex): 支持额度耗尽时按模型池顺序续跑 - #2605
Conversation
|
感谢提交!这个 PR 的评审在飞书群里进行,评审机器人和维护者会在群里讨论修改意见。加群链接:https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=4b6g2a37-29ff-41f5-afa2-241711e80f4c&qr_code=true (一年内有效) |
|
你好,感谢提交!这是自动评审的初步意见,最终结论以维护者审阅为准。 我已把本 PR 与最新 master(c051449ef)做了本地 rebase(无冲突),总体实现质量很好:结构化错误码判定、fail-closed 的额度证据解析、有序只进不退、exact native resume、journal 冻结与取消优先都有真实 Worker/PTY 测试覆盖。发现 1 个合并后必现的测试问题,建议处理: P1:与最新 master 合并后 CI 会红master 最新合入的 #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,并在 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 中的对应守卫后新用例会变红。 两个建议(非阻断)
另外有几个小的防御性点(不阻断),评审详情在维护者群里跟进:parser 中"日窗口已过期 + 周窗口仍当前"的部分证据分支建议补一个单测; 再次感谢,这个功能的边界(不碰普通 429/认证/网络失败、不使用池外模型、不推断跨日重置、at-most-once/adopt/RPC 不续跑)控制得很清楚。 |
70b3b0f to
74e1541
Compare
|
已按建议处理,更新提交
验证(Node 22.22.0 / Bun 1.4.3):
没有向真实群发送测试消息、请求模型推理或人为耗尽额度;也没有更新或重启现有机器人。 |
|
维护者复审在最新 head 上又发现一个合并/全量测试问题(自动评审同步,最终以维护者结论为准): P1:新 head 自身就让两个既有的 worker 源码切片测试变红(共 7 例)这两个测试用
我们在本 PR head 原样树上复现为 处理方式:纯测试 scope 注入,src 零改动请 rebase 到最新
我们已独立验证:补丁后这两个文件 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.tssrc 的功能逻辑维护者已复核无阻断;推上新 head 后我们会再确认 unit 全量(含 bun-test)在该 head 首跑全绿。另:之前提到的 |
74e1541 to
de26214
Compare
|
已按本轮意见更新,提交 本次增量只改三个测试文件,没有改生产逻辑:
已完成验证(Node 22.22.0 / Bun 1.4.3,macOS):
全量已经执行完,结果未全绿,没有重试整套、排除失败文件或放宽断言:
本轮修改的三个文件均不在两套失败名单中;TraeX 自动切换集成测试也不在失败名单中。 为区分 PR 回归与基线问题,另取不含本 PR 的
其余失败尚未逐项完成上游对照,不统一归因为上游问题。日志中另有明确的平台差异,例如 macOS 不支持 GNU 本轮没有更新或重启真实机器人,也未向真实群发送测试消息。 |
|
补充运行时修复,已推送 本次修复TraeX quota 模式首条输入采用延后投递。原 fast-path 直接返回,没有向 controller 登记当前待投递 turn;若 现在在 fast-path 放行时调用 新增回归测试覆盖无 native session ID 和已有 native session ID 两种状态:首次放行 → readiness 清零 → viewport 变化暂缓 → 没有新 idle 事件仍能重试同一 turn;提交后,下一 turn 不能复用陈旧 composer 放行。修复前两例失败,修复后通过。另验证取消、关闭 controller、generation 变化和队首替换会拒绝陈旧重试;移除新增登记动作可再次复现卡住。 已完成验证
本次增量未重跑两套全量测试,因此不宣称新 head 全量全绿。上一 head |
|
已合并,感谢贡献!🎉 squash 落地提交 d6c1d90,保留你的作者署名;落地树与合并预测树逐字一致。 这个功能的边界控制得很到位:只认结构化的 遗留一个非阻塞的防御性 follow-up(不影响本次合并,可另开 PR):
另:仓库的 macOS 14 runner 将于 2026-11-02 退役(brownout 已开始),CI/发布链路迁 macos-15 由我们在 #2628 跟踪,与本 PR 无关。 再次感谢,欢迎继续贡献! |
同步最新 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]>
|
@Cansiny0320 @deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 d6c1d90…0932a460d(4 个提交),同批合入的还有 #2623 #2633 #2624,失败不一定由本 PR 引起。
|
|
🚀 Released in v3.56.0 |
改动
Closes #2604
trigger: "quota";不配置时保持原容量排队策略。usageLimitExceeded/usage_limit_exceeded触发切换。普通 429、排队、网络和认证失败不触发。影响面与边界
仅显式启用 quota 策略的托管 TraeX 终端。其他 CLI、旧容量策略、adopt、RPC、durable / at-most-once 保持原行为。
metadata 缺失不等于无限额度。没有 resetTime 且恢复信息持续缺失时保持停止,并提示用
/model人工恢复。原会话续跑不代表外部工具操作具有通用 exactly-once 保证。首次提交验证
bun run build:通过,包含 TypeScript、脚本与测试 mock 类型检查、Dashboard 构建和资源审计。vitest run test/traex-auto-model.integration.test.ts -t quota:5 passed;真实 Worker/PTY + 模拟 CLI,覆盖有序切换、同一 native session、原输入仅一次、全耗尽停止、普通限流不切换及初始化路径。没有向真实 IM 群发送测试消息,没有创建外部业务数据,也没有人为耗尽账号额度。
界面
实际组件渲染的隔离预览:
评审跟进验证
已按建议处理,更新提交
74e1541c4,并 rebase 到master@42432fe84。dispatch-user-route.test.ts的 4 个ReferenceError,再给测试 scope 注入traexQuotaPending,增加 pending 期间 ready gate 保持关闭的用例。现在该文件 41/41 通过;移除对应守卫后,新断言会失败。traex debug models --remote,均返回models[].slug/business_metadata。一台提供日额度字段internal_daily_usage.isDepleted/resetTime,另一台未提供额度信息;原始输出经过本 PR 的解析函数,分别得到明确未耗尽和 unknown,没有把缺失解释成无限额度。未持久化或发布完整目录。本次未观察到有效周额度,周额度仍只有合成测试验证。验证(Node 22.22.0 / Bun 1.4.3):
bun run build:通过,含 TypeScript、脚本/test mock 类型检查、Dashboard 构建和资源审计。node node_modules/vitest/vitest.mjs run test/traex-auto-model.integration.test.ts -t quota:5 passed。没有向真实群发送测试消息、请求模型推理或人为耗尽额度;也没有更新或重启现有机器人。