fix(proxy): enable semantic response cache for self-hosted installations using installation ID - #1266
Open
Adityakk9031 wants to merge 1 commit into
Open
Adityakk9031 wants to merge 1 commit into
Adityakk9031 wants to merge 1 commit into
Conversation
…ions using installation ID The semantic response cache was previously 100% bypassed in self-hosted and single-tenant deployments because cacheEligible required externalID != "", which is only present in multi-tenant cloud deployments with Stripe organization IDs. This commit introduces cacheTenantKey(installationID, externalID) to fall back to the installation ID UUID string when externalID is empty, matching the intended multi-tenant and single-tenant isolation model documented in internal/router/cache/cache.go. Signed-off-by: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The semantic response cache in
internal/proxywas 100% disabled in self-hosted and single-tenant deployments becausecacheEligiblehard-requiredexternalID != "". In self-hosted mode there is no Stripe organization ID, soexternalIDis empty. However, every installation has a permanent UUID (installationID), andinternal/router/cachewas explicitly designed and documented around isolating cache entries perinstallationID.Changes
cacheTenantKey(installationID uuid.UUID, externalID string) stringhelper ininternal/proxy/service.go. It prioritizesexternalIDwhen present (multi-tenant cloud orgs) and falls back toinstallationID.String()for self-hosted/single-tenant installations.ProxyMessagesandProxyOpenAIChatCompletioncache eligibility checks, lookups, and stores to usetenantKey.internal/proxy/cache_tenant_key_internal_test.gocoveringTestCacheTenantKeypriority andTestSemanticCache_SelfHostedInstallationHitverifying semantic cache hits and tenant isolation for both Anthropic and OpenAI formats without external IDs.Verification
go test -v ./internal/proxy -run "TestCacheTenantKey|TestSemanticCache_SelfHostedInstallationHit"(passed)go test ./internal/router/policy ./internal/architecture(passed)go build ./...(passed)Summary by cubic
Enables the semantic response cache for self-hosted and single-tenant installations, where it was previously always bypassed because cache eligibility required an external Stripe organization ID. The cache key now falls back to the installation UUID when the external ID is empty, isolating cached responses per installation for both Anthropic Messages and OpenAI Chat Completions proxy paths, with tests covering key priority and self-hosted cache hits and tenant isolation.
Written for commit 832a947. Summary will update on new commits.