Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.0 KB
Raw Blame
import assert from "node:assert/strict";
import test from "node:test";
import { readFileSync } from "node:fs";

const source = readFileSync(
  new URL("../../open-sse/handlers/chatCore.ts", import.meta.url),
  "utf8"
);

test("global compression off gates reactive and last-resort context compaction", () => {
  assert.match(
    source,
    /reactiveContextCompactionEnabled\s*=\s*compressionSettingsResult\.enabled\s*&&\s*!compressionExcluded;/
  );
  // #8949 added the !nativeCodexPassthrough guard between the flag and the token check;
  // #16632 routes it through shouldSkipNativeCodexReactiveCompaction (true for native
  // passthrough unless the default-off NATIVE_CODEX_REACTIVE_COMPACTION_ENABLED flag is on).
  assert.match(
    source,
    /reactiveContextCompactionEnabled\s*&&\s*!skipNativeCodexReactiveCompaction\s*&&\s*estimatedTokens\s*>\s*threshold/
  );
  assert.match(
    source,
    /reactiveContextCompactionEnabled\s*&&\s*!skipNativeCodexReactiveCompaction\s*&&\s*finalEstimatedInputTokens\s*>=\s*effectiveCompactionCeiling/
  );
});