diff --git a/apps/server/src/serverSettings.test.ts b/apps/server/src/serverSettings.test.ts index 347b43dd6f44c..16744f8b3f202 100644 --- a/apps/server/src/serverSettings.test.ts +++ b/apps/server/src/serverSettings.test.ts @@ -293,11 +293,11 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("server settings" }).pipe(Effect.provide(layerServerSettings())), ); - it.effect("tells clients it reads idle compaction modes before any settings are saved", () => + it.effect("defaults to never compacting idle threads, and says so in the mode field", () => Effect.gen(function* () { const service = yield* ServerSettingsModule.ServerSettingsService; const settings = yield* service.getSettings; - assert.equal(settings.idleCompaction, "onReturn"); + assert.equal(settings.idleCompaction, "off"); assert.strictEqual(settings.compactIdleThreads, false); }).pipe(Effect.provide(layerServerSettings())), ); diff --git a/apps/server/src/serverSettings.ts b/apps/server/src/serverSettings.ts index 251becba12f6c..f69cd31726b08 100644 --- a/apps/server/src/serverSettings.ts +++ b/apps/server/src/serverSettings.ts @@ -788,6 +788,8 @@ const make = Effect.gen(function* () { let legacyProviders: Readonly> | undefined; let legacySourceControl: Parameters[1] = {}; let parseFailure = Option.none(); + // Whether the file records an idle compaction choice, in either field. + let savedIdleCompaction = false; if (yield* readConfigExists) { const raw = yield* readRawConfig; @@ -817,12 +819,22 @@ const make = Effect.gen(function* () { } } else { settings = decoded.value; + const file: unknown = parsed._tag === "Success" ? parsed.value : undefined; + savedIdleCompaction = + typeof file === "object" && + file !== null && + ("idleCompaction" in file || "compactIdleThreads" in file); } } - // Settings saved by a server that kept the mode in `compactIdleThreads` move - // it to `idleCompaction`, so that switch goes to clients as a boolean. The - // defaults gain the field too, which tells clients this server reads modes. - settings = withIdleCompaction(settings, globalIdleCompaction(settings)); + // Move a legacy `compactIdleThreads` mode to `idleCompaction` (clients read the + // switch as a boolean). The field's presence tells clients this server reads modes. + // Without a saved or policy choice, never compact idle threads. + settings = withIdleCompaction( + settings, + savedIdleCompaction || settings.idleCompaction !== undefined + ? globalIdleCompaction(settings) + : "off", + ); // A file that failed to decode must stay on disk for the user to repair. const settingsFileTrusted = Option.isNone(parseFailure); diff --git a/docs/user/providers-claude.md b/docs/user/providers-claude.md index 9cd403743fb2e..bf9367637695a 100644 --- a/docs/user/providers-claude.md +++ b/docs/user/providers-claude.md @@ -67,7 +67,7 @@ composer commands. **Compact idle threads** in **Settings > Providers > Advanced** controls this for threads over 200,000 tokens. Each Claude provider's settings can override it: -- **When you return** shows the **Compact** chip described above. This is the default. +- **When you return** shows the **Compact** chip described above. - **Before the cache expires (beta)** tries to compact an idle thread shortly before its prompt cache expires, while the history is still cached. The compaction appears in the thread as a `/compact` turn sent by T3 Code. @@ -75,7 +75,8 @@ over 200,000 tokens. Each Claude provider's settings can override it: expired or the server restarts before compaction runs, it falls back to **When you return**. Switch the chip to **Keep** to keep the full history for that message. - **Never** skips idle compaction and Claude's resume prompt. **Auto-compact after** - still applies, and you can still compact by hand. + still applies, and you can still compact by hand. This is the default: how long you + were away says nothing about whether the conversation needs summarizing. ## Usage limits