mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-11 17:52:31 +03:00
The semantic cache signature (generateSignature) was computed over different bodies at read-time vs write-time in handleChatCore. The cache read at Phase 9.1 uses the original body, but the writes at Phase 9.1 (non-streaming) and Phase 9.2 (streaming) used the body after sanitizeChatRequestBody() and injectMemoryAndSkills() mutated messages. Since the digest includes messages, every request stored under a key no later request would look up — 0% hit rate, every request billed. Fix: snapshot bodyForCacheWrite right after the cache read and use it for both write paths, so the write-time signature equals the read-time one. TDD: tests/unit/cache-signature-roundtrip.test.ts proves the mutated body produces a different signature (bug) and the preserved snapshot produces an identical one (fix).