Skip to content

0.8.0: integrations no longer switch the cache off during cold start - #14

Merged
imxinchengyou merged 1 commit into
mainfrom
feat/integrations-cold-start-passthrough
Nov 27, 2026
Merged

imxinchengyou merged 1 commit into
mainfrom
feat/integrations-cold-start-passthrough

Conversation

@imxinchengyou

Copy link
Copy Markdown
Owner

Problem

While a workspace has no model of its own, /v1/verify runs fail-closed and rejects every call. Rejecting only gray-zone calls (the integration pattern in the docs) is cheap. But both integrations send every hit and dropped the notice, so a new user's cache was silently switched off: hit rate went to zero, LLM spend went up, and nothing was protected that wasn't already being served before CacheVerifier was added.

Change

  • VerifiedCache (LangChain): new cold_start="serve" | "reject". The default "serve" serves cold-start hits exactly as the wrapped cache returned them, the same as without VerifiedCache. "reject" keeps the old behavior, which is right if the wrapped cache's threshold was loosened because a verifier would check its hits.
  • CacheVerifierEvaluation (GPTCache): new fallback= for the evaluator it replaces (e.g. SearchDistanceEvaluation()). GPTCache applies similarity_threshold to whatever the evaluator returns, so replacing the evaluator also drops its similarity check. During cold start the fallback's score divided by its range width is returned. GPTCache accepts a hit when rank >= (max - min) * similarity_threshold, so this accepts exactly the hits it accepted before (exact for ranges starting at 0, which all built-in evaluators have). Without a fallback, cold-start hits stay misses, now with a warning saying how to keep them. direct_hit= serves hits whose rescaled fallback score is at least that high without a verify call.
  • The first cold-start verdict per instance is logged once (logger cacheverifier.integrations), including the service's notice.
  • VerifyResult.cold_start property.
  • Version 0.8.0, CHANGELOG, README, GPTCache example.

Deliberately not done

  • GPTCache does not send similarity_score to verify. report_feedback documents the raw vector-search score, so sending a different scale at verify time would make a fitted joint rule see a different scale in production than it was trained on.
  • LangChain can't get a tau_high bypass: BaseCache.lookup doesn't expose the similarity.

Testing

  • pytest -q: 67 passed, 1 skipped. New tests cover serve / reject / warn-once, audit and stock-model rejections still falling through, the GPTCache rescale, the no-fallback case, direct_hit skipping the call, and argument validation.
  • ruff check . and mypy cacheverifier pass.
  • Not run against a real GPTCache install. The rescale was checked against GPTCache's adapter.py threshold code.

While a workspace has no model of its own, /v1/verify rejects every call.
The integrations send every hit, so they rejected all of them and silently
dropped the notice saying why.

- VerifiedCache (LangChain): cold_start="serve" (default) serves cold-start
  hits exactly as the wrapped cache returned them; cold_start="reject" keeps
  the old behavior. The first cold-start verdict is logged once.
- CacheVerifierEvaluation (GPTCache): fallback= takes the evaluator it
  replaces; during cold start its score divided by its range width is
  returned, so GPTCache's similarity_threshold accepts exactly the hits it
  did before. Without a fallback cold-start hits stay misses, with a warning.
  direct_hit= serves hits whose fallback score is at least that high without
  a verify call. similarity_score is deliberately not sent to verify, so it
  can't diverge from the raw scale report_feedback documents.
- VerifyResult.cold_start property.
@imxinchengyou
imxinchengyou merged commit 49e33a0 into main Nov 27, 2026
7 checks passed
@imxinchengyou
imxinchengyou deleted the feat/integrations-cold-start-passthrough branch November 27, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant