@sleep2agi/commhub-server 0.9.0-preview.177 → 0.9.0-preview.178
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/commhub-server",
|
|
3
|
-
"version": "0.9.0-preview.
|
|
3
|
+
"version": "0.9.0-preview.178",
|
|
4
4
|
"description": "CommHub Server — AI Agent communication hub with MCP protocol, multi-network isolation, user auth, and MCP tools (17 collaboration-core + node/provider ops tools; authoritative list: docs-site/docs/api/mcp-tools.md).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -242,6 +242,8 @@ export function applyFailureBackoff(scheduleId: string, now = new Date()): { str
|
|
|
242
242
|
* · 与 `no_change_backoff=1` 的排程互斥(那套逻辑自己拥有 backoff_* 三列)。
|
|
243
243
|
*/
|
|
244
244
|
const NO_PROGRESS_CODES = ["previous_run_active", "target_offline"] as const;
|
|
245
|
+
/** 统计窗口:看最近多少次 run 里同因跳过出现了几次(默认 10)。 */
|
|
246
|
+
const NO_PROGRESS_WINDOW = 10;
|
|
245
247
|
export type NoProgressCause = (typeof NO_PROGRESS_CODES)[number];
|
|
246
248
|
|
|
247
249
|
function noProgressFromRuns(runs: Array<{ status: string; error_code: string | null }>): { cause: NoProgressCause | null; streak: number } {
|
|
@@ -253,10 +255,16 @@ function noProgressFromRuns(runs: Array<{ status: string; error_code: string | n
|
|
|
253
255
|
cause = first.error_code as NoProgressCause;
|
|
254
256
|
}
|
|
255
257
|
if (!cause) return { cause: null, streak: 0 };
|
|
258
|
+
// #2622(实测修正)—— **按窗口计数,不按连续链**。
|
|
259
|
+
// 生产 4.3 小时实测:一批排程的模式是「跳过 → 跳过 → 成功 → 跳过…」,
|
|
260
|
+
// 成功会把连续链打断,于是 streak 永远攒不到阈值,退避一次都没触发
|
|
261
|
+
// (previous_run_active 24h 从 2397/天 只降到 2258/天)。
|
|
262
|
+
// 改成「最近 N 次里同因跳过出现几次」:仍然要求最新一次是同因跳过(不干扰成功后的恢复),
|
|
263
|
+
// 但如果它在这 N 次里反复出现,就按窗口值放慢。
|
|
264
|
+
const window = runs.slice(0, NO_PROGRESS_WINDOW);
|
|
256
265
|
let streak = 0;
|
|
257
|
-
for (const r of
|
|
258
|
-
if (r.status
|
|
259
|
-
streak++;
|
|
266
|
+
for (const r of window) {
|
|
267
|
+
if (r.status === "skipped" && r.error_code === cause) streak++;
|
|
260
268
|
}
|
|
261
269
|
return { cause, streak };
|
|
262
270
|
}
|
|
@@ -108,6 +108,22 @@ describe("applyNoProgressBackoff (#2622)", () => {
|
|
|
108
108
|
expect(applyNoProgressBackoff(id)).toBeNull();
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
+
|
|
112
|
+
test("alternating skip/success pattern still backs off (window, not strict chain)", () => {
|
|
113
|
+
// 生产实测:一批排程是「跳过 → 跳过 → 成功 → 跳过…」,成功会把连续链打断,
|
|
114
|
+
// 按严格链计数永远攒不到阈值。窗口计数必须能抓住它。
|
|
115
|
+
const id = seedSchedule(180);
|
|
116
|
+
addRun(id, "skipped", "previous_run_active");
|
|
117
|
+
addRun(id, "skipped", "previous_run_active");
|
|
118
|
+
addRun(id, "replied", null); // 成功打断链
|
|
119
|
+
addRun(id, "skipped", "previous_run_active");
|
|
120
|
+
const r = applyNoProgressBackoff(id);
|
|
121
|
+
expect(r).not.toBeNull();
|
|
122
|
+
expect(r!.cause).toBe("previous_run_active");
|
|
123
|
+
expect(r!.streak).toBe(3);
|
|
124
|
+
expect(r!.effective_seconds).toBeGreaterThan(180);
|
|
125
|
+
});
|
|
126
|
+
|
|
111
127
|
test("schedules that opt into no_change_backoff are left to the other mechanism", () => {
|
|
112
128
|
const id = seedSchedule(180, { no_change_backoff: 1 });
|
|
113
129
|
for (let i = 0; i < 5; i++) addRun(id, "skipped", "target_offline");
|