@devries-cameron20 / t3code-1 / commits / 5f95653f25
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): Claude context meter no longer shows an auto-compact point when auto-compaction is off (#36417)

Julius Marminge committed Nov 13, 2026 at 14:34 UTC 5f95653f25ae0f5655145fa83d94d618c2951432
2 files changed +36
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+12
@@ -9109,6 +9109,18 @@ describe("ClaudeAdapterV2 background wake turns", () => {
9109 environment: { CLAUDE_CODE_AUTO_COMPACT_WINDOW: "300000" },
9110 threshold: 267_000,
9111 },
9112 + {
9113 + autoCompactWindow: "",
9114 + model: "claude-opus-5-5",
9115 + userSettings: '{"autoCompactWindow":400000,"autoCompactEnabled":false}',
9116 + threshold: undefined,
9117 + },
9118 + {
9119 + autoCompactWindow: "400000",
9120 + model: "claude-opus-5-5",
9121 + environment: { DISABLE_AUTO_COMPACT: "1" },
9122 + threshold: undefined,
9123 + },
9124 ])(
9125 "ignores stale snapshots after compaction and reports threshold $autoCompactWindow for $model",
9126 ({
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+24
@@ -270,6 +270,11 @@ function claudePromptCacheTtlMs(
270 // getContextUsage reports a 150,000 window as a 117,000 threshold, for every catalog model.
271 const CLAUDE_AUTO_COMPACT_RESERVE_TOKENS = 33_000;
272
273 +// Claude Code's isEnvTruthy.
274 +function isClaudeEnvTruthy(value: string | undefined): boolean {
275 + return value !== undefined && ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
276 +}
277 +
278 function claudeAutoCompactThreshold(autoCompactWindow: string, maxTokens: number | null) {
279 const windowTokens = Number(autoCompactWindow);
280 return windowTokens > 0 && (maxTokens === null || windowTokens < maxTokens)
@@ -3260,6 +3265,7 @@ const decodeClaudeSubagentCacheSettings = Schema.decodeUnknownEffect(
3265 const decodeClaudeCompactSettings = Schema.decodeUnknownEffect(
3266 Schema.fromJsonString(
3267 Schema.Struct({
3268 + autoCompactEnabled: Schema.optionalKey(Schema.Unknown),
3269 autoCompactWindow: Schema.optionalKey(Schema.Unknown),
3270 modelSettings: Schema.optionalKey(Schema.Unknown),
3271 }),
@@ -5473,6 +5479,24 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
5479 modelSelection: ModelSelection,
5480 launchArgSettings: ClaudeSdkSettings | undefined,
5481 ) {
5482 + // With auto-compaction off Claude never compacts, so there is no threshold to report.
5483 + for (const name of ["DISABLE_COMPACT", "DISABLE_AUTO_COMPACT"]) {
5484 + const value = yield* resolveClaudeEnv(cwd, launchArgSettings, name);
5485 + if (isClaudeEnvTruthy(value)) return "";
5486 + }
5487 + const launchEnabled = launchArgSettings?.autoCompactEnabled;
5488 + let autoCompactEnabled = typeof launchEnabled === "boolean" ? launchEnabled : undefined;
5489 + for (const settingsFile of yield* settingsFilesByPrecedence(cwd)) {
5490 + if (autoCompactEnabled !== undefined) break;
5491 + const settings = yield* fileSystem.readFileString(settingsFile).pipe(
5492 + Effect.flatMap(decodeClaudeCompactSettings),
5493 + Effect.orElseSucceed(() => undefined),
5494 + );
5495 + if (typeof settings?.autoCompactEnabled === "boolean") {
5496 + autoCompactEnabled = settings.autoCompactEnabled;
5497 + }
5498 + }
5499 + if (autoCompactEnabled === false) return "";
5500 if (adapterOptions.settings.autoCompactWindow !== "")
5501 return adapterOptions.settings.autoCompactWindow;
5502 const validWindow = (value: unknown) => {