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
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import {
isCompressionExcluded,
normalizeCompressionExclusions,
} from "../../open-sse/services/compression/exclusions.ts";
const chatCoreSource = readFileSync(
new URL("../../open-sse/handlers/chatCore.ts", import.meta.url),
"utf8"
);
// Regression guard for https://github.com/diegosouzapw/OmniRoute/issues/12793:
// native Codex passthrough (`POST /v1/responses`, provider `codex`) silently stopped
// producing compression analytics (100% `skip_reason='excluded'`) after #8933 added
// `nativeCodexPassthrough ||` to the prompt-compression exclusion (landed on release
// via #11088). Prompt compression must depend ONLY on the operator exclusions list.
test("codex prompt compression is not gated on native passthrough", () => {
const match = chatCoreSource.match(/const compressionExcluded =([\s\S]*?);/);
assert.ok(match, "compressionExcluded assignment must exist in chatCore.ts");
assert.doesNotMatch(
match[1],
/nativeCodexPassthrough/,
"prompt-compression exclusion must not reference nativeCodexPassthrough"
);
assert.match(match[1], /isCompressionExcluded/);
});
test("codex target is compressible by default; operators can still opt out via exclusions", () => {
assert.equal(
isCompressionExcluded(
{ provider: "codex", model: "gpt-5.6-terra" },
normalizeCompressionExclusions([])
),
false
);
assert.equal(
isCompressionExcluded(
{ provider: "codex", model: "gpt-5.6-terra" },
normalizeCompressionExclusions(["codex/*"])
),
true
);
});
test("prompt-only scope: reactive compaction still bypasses native passthrough", () => {
// Deliberately left for follow-up (overflow fail-fast + history-rewriting safety).
// If these gates are ever lifted, update the PR body notes, not just this test.
// #16632: the bypass is now lifted ONLY by the default-off
// NATIVE_CODEX_REACTIVE_COMPACTION_ENABLED flag; with the flag off the guard is
// exactly `nativeCodexPassthrough` (behavior proven end-to-end in
// native-codex-passthrough-compaction.test.ts).
assert.match(
chatCoreSource,
/skipNativeCodexReactiveCompaction\s*=\s*shouldSkipNativeCodexReactiveCompaction\(\s*nativeCodexPassthrough,/
);
assert.match(
chatCoreSource,
/reactiveContextCompactionEnabled\s*&&\s*!skipNativeCodexReactiveCompaction\s*&&\s*estimatedTokens\s*>\s*threshold/
);
assert.match(
chatCoreSource,
/reactiveContextCompactionEnabled\s*&&\s*!skipNativeCodexReactiveCompaction\s*&&\s*finalEstimatedInputTokens\s*>=\s*effectiveCompactionCeiling/
);
});