Skip to content

perf(ai-gateway): read routing credentials from replicas - #4881

Merged
chrarnoldus merged 1 commit into
mainfrom
perf/ai-gateway-readonly-routing
Jul 30, 2026
Merged

perf(ai-gateway): read routing credentials from replicas#4881
chrarnoldus merged 1 commit into
mainfrom
perf/ai-gateway-readonly-routing

Conversation

@chrarnoldus

Copy link
Copy Markdown
Contributor

Summary

  • use readDb for direct and Vercel BYOK credential lookup during AI gateway provider resolution
  • use readDb for custom LLM provider lookup
  • use readDb for request-time Organization Auto BYOK validation while preserving explicitly supplied primary transactions for admin mutations
  • assert that embedding BYOK resolution receives the readonly client

Consistency

These request-time reads may briefly observe stale credential or configuration state during replica lag. Write paths and transaction-scoped Organization Auto validation remain on the primary.

Validation

  • pnpm exec oxfmt --list-different apps/web/src/lib/ai-gateway/providers/get-provider.ts apps/web/src/lib/ai-gateway/providers/getEmbeddingProvider.test.ts apps/web/src/lib/organizations/organization-auto-model.ts
  • pnpm exec oxlint --config .oxlintrc.json apps/web/src/lib/ai-gateway/providers/get-provider.ts apps/web/src/lib/ai-gateway/providers/getEmbeddingProvider.test.ts apps/web/src/lib/organizations/organization-auto-model.ts
  • pnpm --filter web test --runInBand --runTestsByPath src/lib/ai-gateway/providers/getEmbeddingProvider.test.ts src/routers/organizations/organization-settings-router.test.ts src/routers/organizations/organization-modes-router.test.ts
  • pnpm --filter web typecheck
  • git diff --check

@chrarnoldus chrarnoldus self-assigned this Jul 30, 2026
@kilo-code-bot

kilo-code-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Mechanical swap of primary db reads to readDb for AI-gateway provider/BYOK routing lookups, correctly preserving explicit transaction/dbClient overrides on write paths, with no issues found.

Files Reviewed (3 files)
  • apps/web/src/lib/ai-gateway/providers/get-provider.ts
  • apps/web/src/lib/ai-gateway/providers/getEmbeddingProvider.test.ts
  • apps/web/src/lib/organizations/organization-auto-model.ts

Reviewed by claude-sonnet-5 · Input: 16 · Output: 3.2K · Cached: 325.8K

Review guidance: REVIEW.md from base branch main

@chrarnoldus
chrarnoldus merged commit 0f86cad into main Jul 30, 2026
16 checks passed
@chrarnoldus
chrarnoldus deleted the perf/ai-gateway-readonly-routing branch July 30, 2026 12:03
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.

2 participants