From 295f07d111ab043b90cb99a2bf0fcf559b963707 Mon Sep 17 00:00:00 2001 From: Hong Jiarong Date: Thu, 30 Jul 2026 17:11:42 +0800 Subject: [PATCH] fix(hub): enable SDK auto-compact for resumed sessions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sessions resume across runs (ADR-0017). Without auto-compact the SDK jsonl grows unboundedly — a 7-day / 26-run session hit 31 MB / 1995 lines, making every API call resend the full history and inflating a trivial "change a title" task to 22 minutes. Enable autoCompactEnabled in the SDK settings so the SDK compacts automatically when the context window fills. --- hub/src/agent/runner.ts | 6 ++++++ hub/test/unit/runner.test.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hub/src/agent/runner.ts b/hub/src/agent/runner.ts index 76f25f8..d9d962b 100644 --- a/hub/src/agent/runner.ts +++ b/hub/src/agent/runner.ts @@ -211,6 +211,12 @@ export async function runAgent(req: RunRequest): Promise { settings: { disableBundledSkills: true, todoFeatureEnabled: true, + // Sessions are resumed across runs (ADR-0017). Without auto-compact + // the SDK jsonl grows unboundedly — a long-lived project session hit + // 31 MB / 1995 lines, making every API call resend the entire history + // and inflating a "change a title" task to 22 minutes. Let the SDK + // compact automatically when the context window fills. + autoCompactEnabled: true, }, ...(hasSkills && security.skillPluginRoot !== undefined ? { plugins: [{ type: "local" as const, path: security.skillPluginRoot, skipMcpDiscovery: true }] } diff --git a/hub/test/unit/runner.test.ts b/hub/test/unit/runner.test.ts index 71e6805..24d51d0 100644 --- a/hub/test/unit/runner.test.ts +++ b/hub/test/unit/runner.test.ts @@ -113,7 +113,7 @@ describe("runAgent", () => { permissionMode: "bypassPermissions", allowDangerouslySkipPermissions: true, settingSources: [], - settings: { disableBundledSkills: true, todoFeatureEnabled: true }, + settings: { disableBundledSkills: true, todoFeatureEnabled: true, autoCompactEnabled: true }, tools: expect.arrayContaining(["Read", "Write", "Edit", "Bash", "Glob", "Grep", "TodoWrite"]), allowedTools: expect.arrayContaining(["TodoWrite", "mcp__cph_hub__todo_write"]), disallowedTools: expect.arrayContaining(["Agent", "SendMessage", "Task", "TeamCreate", "ScheduleWakeup"]),