From 65edddd62e54695fe11260f8fe3db8546b9d440f Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Sat, 28 Mar 2026 17:26:55 -0300 Subject: [PATCH] refactor(open-sse): remove unused imports from translator/index.ts remove unused imports coerceToolSchemas and sanitizeToolDescriptions from translator/index.ts to satisfy lint and prevent unused import issues --- open-sse/translator/index.ts | 1 - src/lib/db/settings.ts | 1 - tests/unit/call-log-cap.test.mjs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/open-sse/translator/index.ts b/open-sse/translator/index.ts index 731d710c90..d8d558abde 100644 --- a/open-sse/translator/index.ts +++ b/open-sse/translator/index.ts @@ -1,6 +1,5 @@ import { FORMATS } from "./formats.ts"; import { ensureToolCallIds, fixMissingToolResponses } from "./helpers/toolCallHelper.ts"; -import { coerceToolSchemas, sanitizeToolDescriptions } from "./helpers/schemaCoercion.ts"; import { prepareClaudeRequest } from "./helpers/claudeHelper.ts"; import { filterToOpenAIFormat } from "./helpers/openaiHelper.ts"; import { diff --git a/src/lib/db/settings.ts b/src/lib/db/settings.ts index 347a648a50..e5ac9f6553 100644 --- a/src/lib/db/settings.ts +++ b/src/lib/db/settings.ts @@ -45,7 +45,6 @@ export async function getSettings() { cloudEnabled: false, stickyRoundRobinLimit: 3, requireLogin: true, - maxCallLogs: 10000, }; for (const row of rows) { const record = toRecord(row); diff --git a/tests/unit/call-log-cap.test.mjs b/tests/unit/call-log-cap.test.mjs index 77cb290327..314fe13bdd 100644 --- a/tests/unit/call-log-cap.test.mjs +++ b/tests/unit/call-log-cap.test.mjs @@ -6,6 +6,7 @@ import path from "node:path"; const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-calllogs-cap-")); process.env.DATA_DIR = TEST_DATA_DIR; +const ORIGINAL_CALL_LOGS_MAX = process.env.CALL_LOGS_MAX; const core = await import("../../src/lib/db/core.ts"); const localDb = await import("../../src/lib/localDb.ts"); @@ -25,6 +26,11 @@ test.beforeEach(async () => { test.after(() => { core.resetDbInstance(); fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true }); + if (ORIGINAL_CALL_LOGS_MAX === undefined) { + delete process.env.CALL_LOGS_MAX; + } else { + process.env.CALL_LOGS_MAX = ORIGINAL_CALL_LOGS_MAX; + } }); test("call logs respect the configurable maxCallLogs setting", async () => { @@ -52,3 +58,29 @@ test("call logs respect the configurable maxCallLogs setting", async () => { ["model-5", "model-4", "model-3"] ); }); + +test("call logs keep honoring CALL_LOGS_MAX when maxCallLogs was never saved", async () => { + process.env.CALL_LOGS_MAX = "2"; + callLogs.invalidateCallLogsMaxCache(); + + for (let i = 1; i <= 4; i++) { + await callLogs.saveCallLog({ + method: "POST", + path: "/v1/chat/completions", + status: 200, + model: `env-model-${i}`, + provider: "openai", + duration: i, + requestBody: { index: i }, + responseBody: { ok: true, index: i }, + }); + } + + const logs = await callLogs.getCallLogs({ limit: 10 }); + + assert.equal(logs.length, 2); + assert.deepEqual( + logs.map((entry) => entry.model), + ["env-model-4", "env-model-3"] + ); +});