mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 22:32:12 +03:00
- fix(memory): wrap JSON.parse in try/catch in retrieval.ts to prevent 500 on corrupt metadata; add stats to GET /api/memory response - fix(#949): add sanitizeToolId() to replace invalid chars in cross-provider tool IDs; clamp max_tokens to Math.max(1, value) - feat(skills): add SkillsMP marketplace integration (search + install via /api/skills/marketplace); add skill upload/install modal and DELETE endpoint; wire skillsEnabled guard in executor - feat(settings): add Maintenance section to General tab (Clear Cache + Purge Expired Logs buttons) - feat(lkgp): add lkgpEnabled toggle and Clear LKGP Cache button to Routing settings; add clearAllLKGP(); respect toggle in LKGPStrategyImpl - test: add vitest coverage for all new functionality Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25 lines
747 B
TypeScript
25 lines
747 B
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { adjustMaxTokens } from "../maxTokensHelper.ts";
|
|
|
|
describe("adjustMaxTokens - negative values", () => {
|
|
it("clamps large negative max_tokens to 1", () => {
|
|
const result = adjustMaxTokens({ max_tokens: -36398 });
|
|
expect(result).toBe(1);
|
|
});
|
|
|
|
it("clamps -1 max_tokens to 1", () => {
|
|
const result = adjustMaxTokens({ max_tokens: -1 });
|
|
expect(result).toBe(1);
|
|
});
|
|
|
|
it("does not clamp positive values", () => {
|
|
const result = adjustMaxTokens({ max_tokens: 4096 });
|
|
expect(result).toBe(4096);
|
|
});
|
|
|
|
it("uses DEFAULT_MAX_TOKENS when max_tokens is 0 or undefined", () => {
|
|
const result = adjustMaxTokens({});
|
|
expect(result).toBeGreaterThan(0);
|
|
});
|
|
});
|