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
/**
 * Native Codex passthrough (`POST /v1/responses` → provider `codex`) is kept out of the
 * reactive and last-resort context compaction passes by default: those passes rewrite
 * the conversation history the Codex client owns (history-rewriting safety, #8949).
 *
 * `NATIVE_CODEX_REACTIVE_COMPACTION_ENABLED` (default off) lets an operator opt native
 * Codex histories into the same reactive compaction every other request already gets
 * (#16632). The flag resolver is injected so this module stays free of `src/` imports
 * (open-sse → src boundary), and any resolver failure fails closed — the exclusion holds.
 */
export const NATIVE_CODEX_REACTIVE_COMPACTION_FLAG = "NATIVE_CODEX_REACTIVE_COMPACTION_ENABLED";

export function shouldSkipNativeCodexReactiveCompaction(
  nativeCodexPassthrough: boolean,
  isFlagEnabled: (key: string) => boolean
): boolean {
  if (!nativeCodexPassthrough) return false;
  try {
    return !isFlagEnabled(NATIVE_CODEX_REACTIVE_COMPACTION_FLAG);
  } catch {
    return true;
  }
}