Skip to content

fix(proxy): enable semantic response cache for self-hosted installations using installation ID - #1266

Open
Adityakk9031 wants to merge 1 commit into
weave-os:mainfrom
Adityakk9031:fix/cache-selfhosted-tenant-key
Open

Adityakk9031 wants to merge 1 commit into
weave-os:mainfrom
Adityakk9031:fix/cache-selfhosted-tenant-key

Conversation

@Adityakk9031

@Adityakk9031 Adityakk9031 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Description

The semantic response cache in internal/proxy was 100% disabled in self-hosted and single-tenant deployments because cacheEligible hard-required externalID != "". In self-hosted mode there is no Stripe organization ID, so externalID is empty. However, every installation has a permanent UUID (installationID), and internal/router/cache was explicitly designed and documented around isolating cache entries per installationID.

Changes

  • Added cacheTenantKey(installationID uuid.UUID, externalID string) string helper in internal/proxy/service.go. It prioritizes externalID when present (multi-tenant cloud orgs) and falls back to installationID.String() for self-hosted/single-tenant installations.
  • Updated ProxyMessages and ProxyOpenAIChatCompletion cache eligibility checks, lookups, and stores to use tenantKey.
  • Added unit tests in internal/proxy/cache_tenant_key_internal_test.go covering TestCacheTenantKey priority and TestSemanticCache_SelfHostedInstallationHit verifying 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.

Review in cubic

…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>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

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