feat(providers): add configurable OpenRouter and Gemini base URLs#963
feat(providers): add configurable OpenRouter and Gemini base URLs#963ipirojnoe wants to merge 2 commits into
Conversation
Signed-off-by: Ilia <idemin@aol.com>
Signed-off-by: Ilia <idemin@aol.com>
|
Someone is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdds a new ChangesConfigurable base URL for Gemini and OpenRouter
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/fetch-timeout.test.ts`:
- Around line 122-129: The afterEach hook unconditionally deletes the
AGENTMEMORY_LLM_TIMEOUT_MS environment variable without checking if it existed
before the test suite ran, which can cause cross-test interference. Store the
original value of AGENTMEMORY_LLM_TIMEOUT_MS (if it exists) before the
beforeEach hook sets it, then in the afterEach hook restore the original value
if it existed, or only delete it if it didn't exist before the test suite
started. This ensures the environment is left in its original state after the
test completes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: defbafe8-0f98-44da-8e4c-3280c448cdbc
📒 Files selected for processing (12)
.env.exampleREADME.mdsrc/config.tssrc/providers/embedding/gemini.tssrc/providers/embedding/openrouter.tssrc/providers/gemini.tssrc/providers/index.tssrc/providers/openrouter.tstest/fallback-model-resolution.test.tstest/fetch-timeout.test.tstest/gemini-provider.test.tstest/openrouter-provider.test.ts
| beforeEach(() => { | ||
| vi.spyOn(globalThis, "fetch").mockImplementation(hangingFetch as typeof fetch); | ||
| process.env["AGENTMEMORY_LLM_TIMEOUT_MS"] = "50"; | ||
| }); | ||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| delete process.env["AGENTMEMORY_LLM_TIMEOUT_MS"]; | ||
| }); |
There was a problem hiding this comment.
Preserve pre-existing timeout env var in teardown.
The suite always deletes AGENTMEMORY_LLM_TIMEOUT_MS in afterEach, which can clobber a value that existed before this suite ran and cause cross-test interference.
Proposed fix
+const originalTimeoutMs = process.env["AGENTMEMORY_LLM_TIMEOUT_MS"];
+
describe("Provider hang regression — GeminiProvider", () => {
beforeEach(() => {
vi.spyOn(globalThis, "fetch").mockImplementation(hangingFetch as typeof fetch);
process.env["AGENTMEMORY_LLM_TIMEOUT_MS"] = "50";
});
afterEach(() => {
vi.restoreAllMocks();
- delete process.env["AGENTMEMORY_LLM_TIMEOUT_MS"];
+ if (originalTimeoutMs === undefined) {
+ delete process.env["AGENTMEMORY_LLM_TIMEOUT_MS"];
+ } else {
+ process.env["AGENTMEMORY_LLM_TIMEOUT_MS"] = originalTimeoutMs;
+ }
});🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/fetch-timeout.test.ts` around lines 122 - 129, The afterEach hook
unconditionally deletes the AGENTMEMORY_LLM_TIMEOUT_MS environment variable
without checking if it existed before the test suite ran, which can cause
cross-test interference. Store the original value of AGENTMEMORY_LLM_TIMEOUT_MS
(if it exists) before the beforeEach hook sets it, then in the afterEach hook
restore the original value if it existed, or only delete it if it didn't exist
before the test suite started. This ensures the environment is left in its
original state after the test completes.
What
Adds configurable base URLs for OpenRouter and Gemini.
OPENROUTER_BASE_URLis used by OpenRouter chat completions and embeddings.GEMINI_BASE_URLis used by Gemini OpenAI-compatible chat completions and native embeddings.OpenRouterProvider.Why
OpenRouter endpoints were hardcoded, so deployments using an OpenRouter compatible proxy could not route LLM and embedding requests through it. Separating Gemini removes provider behavior inferred from the URL.
Verification
npm run buildnpm testSummary by CodeRabbit
New Features
Documentation
Tests