mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 05:12:11 +03:00
OpenAI / Codex / Azure-OpenAI use automatic prefix caching: the upstream caches the longest matching prefix of a request (system prompt + earliest messages) WITHOUT any explicit cache_control markers. The cache-aware compression guard only protected that prefix when the body carried explicit cache_control, so for automatic-cache providers the guard was skipped — and with compression active + preserveSystemPrompt:false (or a prefix-compressing mode) it rewrote the prefix, guaranteeing a cache miss and higher token spend through OmniRoute than going direct. getCacheAwareStrategy now treats isCachingProvider alone as sufficient to skip the system prompt and downgrade aggressive/ultra (the explicit cache_control path is a subset). openai/codex/azure are added to CACHING_PROVIDERS so they are recognized as automatic-cache providers (this also activates the intended prompt_cache_key cache-routing hint for OpenAI in chatCore). Compression remains off by default — this only affects operators who enabled it with prefix preservation turned off. TDD: tests/unit/compression-cache-guard-3955.test.ts (RED 5/7 fail → GREEN 7/7). Aligned the existing cachingAware / strategySelector-cache-aware / cache-control-policy / cache-control-claude-providers tests that encoded the old (buggy) "openai is non-caching" behavior. Refs #3955