Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(perf): 额度更新只丢弃连续重复,保留最近 bucket 顺序
Dash71c2e1ceafb9
diff --git a/packages/maker-core/src/agents/codex/app-server/host.test.ts b/packages/maker-core/src/agents/codex/app-server/host.test.tsindex afb207503f..7cccbadaa6 100644--- a/packages/maker-core/src/agents/codex/app-server/host.test.ts+++ b/packages/maker-core/src/agents/codex/app-server/host.test.ts@@ -261,7 +261,7 @@ describe('AppServerHost assistant text delta routing', () => {// ~3.5s 一条 account_usage), 但内容变化仍立即下发, 且晚到的 subscriber 仍能经 replay// 立即拿到当前配额 (Codex chip 冷启动依赖它)。describe('AppServerHost account rate limit fan-out', () => {- it('fans out only changed snapshots per limitId and still replays the latest to late subscribers', async () => {+ it('drops only consecutive duplicate snapshots (keeping bucket order) and still replays the latest to late subscribers', async () => {const transport = new NotificationTransport();const host = new AppServerHost({createTransport: () => transport,@@ -285,6 +285,7 @@ describe('AppServerHost account rate limit fan-out', () => {expect(early.mock.calls.map(([p]) => [p.rateLimits.limitId, p.rateLimits.primary.usedPercent])).toEqual([['codex', 10],['codex_spark', 10],+ ['codex', 10],['codex', 20],]);@@ -295,7 +296,7 @@ describe('AppServerHost account rate limit fan-out', () => {['codex_spark', 10],['codex', 20],]);- expect(early).toHaveBeenCalledTimes(3);+ expect(early).toHaveBeenCalledTimes(4);// 无 limitId 的稀疏更新不去重, 且仅在它是最新一条时才排在回放最后。const sparse = { method: 'account/rateLimits/updated', params: { rateLimits: { primary: { usedPercent: 30, windowDurationMins: 300, resetsAt: 1 } } } };diff --git a/packages/maker-core/src/agents/codex/app-server/host.ts b/packages/maker-core/src/agents/codex/app-server/host.tsindex 88f757df5d..8d1faa9954 100644--- a/packages/maker-core/src/agents/codex/app-server/host.ts+++ b/packages/maker-core/src/agents/codex/app-server/host.ts@@ -386,10 +386,10 @@ export class AppServerHost {*/private lastIdlessAccountRateLimits: AccountRateLimitsUpdatedNotification['params'] | null = null;/**- * 按 limitId 记录最近一次已 fan-out 的配额 payload (JSON)。app-server 会以秒级间隔+ * 记录最近一次已 fan-out 的配额 payload (limitId + JSON), 仅用于丢弃连续重复。app-server 会以秒级间隔* 重复推送内容不变的快照 (实测 ~64% 与上一条相同), 相同内容不再重复广播与记日志。*/- private readonly lastFannedOutRateLimitsJson = new Map<string, string>();+ private lastFannedOutRateLimitsKey: string | null = null;private shuttingDown = false;private shutdownPromise: Promise<void> | null = null;@@ -1221,12 +1221,14 @@ export class AppServerHost {this.lastAccountRateLimits.delete(limitKey);this.lastAccountRateLimits.set(limitKey, p);this.lastIdlessAccountRateLimits = null;- if (this.lastFannedOutRateLimitsJson.get(limitKey) === rawJson) return;- this.lastFannedOutRateLimitsJson.set(limitKey, rawJson);} else {- // 无 limitId 的更新目标 bucket 取决于前一条, 不去重, 始终广播。this.lastIdlessAccountRateLimits = p;}+ // 只丢弃与上一条已广播更新完全相同的连续重复: 它不改变「最近观察的 bucket」, 下游+ // (usageBroadcaster) 依赖这个顺序把稀疏更新合并进正确的 bucket; A,B,A 中最后的 A 不能丢。+ const fanOutKey = `${limitKey ?? ''}\u0000${rawJson}`;+ if (this.lastFannedOutRateLimitsKey === fanOutKey) return;+ this.lastFannedOutRateLimitsKey = fanOutKey;this.logger.debug('accountRateLimits fan-out', {subscribers: this.subscribers.size,rawJson,