mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-20 21:51:28 +00:00
test: prune low-signal live model sweeps
This commit is contained in:
@@ -5,6 +5,19 @@ export type ModelRef = {
|
||||
id?: string | null;
|
||||
};
|
||||
|
||||
function isHighSignalClaudeModelId(id: string): boolean {
|
||||
if (!/\bclaude\b/i.test(id)) {
|
||||
return true;
|
||||
}
|
||||
if (/\bhaiku\b/i.test(id)) {
|
||||
return false;
|
||||
}
|
||||
if (/\bclaude-3(?:[-.]5|[-.]7)\b/i.test(id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function isModernModelRef(ref: ModelRef): boolean {
|
||||
const provider = ref.provider?.trim().toLowerCase() ?? "";
|
||||
const id = ref.id?.trim().toLowerCase() ?? "";
|
||||
@@ -24,3 +37,11 @@ export function isModernModelRef(ref: ModelRef): boolean {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isHighSignalLiveModelRef(ref: ModelRef): boolean {
|
||||
const id = ref.id?.trim().toLowerCase() ?? "";
|
||||
if (!isModernModelRef(ref) || !id) {
|
||||
return false;
|
||||
}
|
||||
return isHighSignalClaudeModelId(id);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ vi.mock("../plugins/provider-runtime.js", () => ({
|
||||
resolveProviderModernModelRef: providerRuntimeMocks.resolveProviderModernModelRef,
|
||||
}));
|
||||
|
||||
import { isModernModelRef } from "./live-model-filter.js";
|
||||
import { isHighSignalLiveModelRef, isModernModelRef } from "./live-model-filter.js";
|
||||
import { normalizeModelCompat } from "./model-compat.js";
|
||||
|
||||
const baseModel = (): Model<Api> =>
|
||||
@@ -379,3 +379,27 @@ describe("isModernModelRef", () => {
|
||||
expect(isModernModelRef({ provider: "opencode", id: "minimax-m2.7" })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isHighSignalLiveModelRef", () => {
|
||||
it("keeps modern higher-signal Claude families", () => {
|
||||
providerRuntimeMocks.resolveProviderModernModelRef.mockImplementation(({ provider, context }) =>
|
||||
provider === "anthropic" && ["claude-sonnet-4-5", "claude-opus-4-5"].includes(context.modelId)
|
||||
? true
|
||||
: undefined,
|
||||
);
|
||||
|
||||
expect(isHighSignalLiveModelRef({ provider: "anthropic", id: "claude-sonnet-4-5" })).toBe(true);
|
||||
expect(isHighSignalLiveModelRef({ provider: "anthropic", id: "claude-opus-4-5" })).toBe(true);
|
||||
});
|
||||
|
||||
it("drops low-signal or old Claude variants even when provider marks them modern", () => {
|
||||
providerRuntimeMocks.resolveProviderModernModelRef.mockReturnValue(true);
|
||||
|
||||
expect(
|
||||
isHighSignalLiveModelRef({ provider: "anthropic", id: "claude-haiku-4-5-20251001" }),
|
||||
).toBe(false);
|
||||
expect(
|
||||
isHighSignalLiveModelRef({ provider: "opencode", id: "claude-3-5-haiku-20241022" }),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
isAnthropicBillingError,
|
||||
isAnthropicRateLimitError,
|
||||
} from "./live-auth-keys.js";
|
||||
import { isModernModelRef } from "./live-model-filter.js";
|
||||
import { isHighSignalLiveModelRef } from "./live-model-filter.js";
|
||||
import { isLiveProfileKeyModeEnabled, isLiveTestEnabled } from "./live-test-helpers.js";
|
||||
import { getApiKeyForModel, requireApiKey } from "./model-auth.js";
|
||||
import { shouldSuppressBuiltInModel } from "./model-suppression.js";
|
||||
@@ -388,7 +388,7 @@ describeLive("live models (profile keys)", () => {
|
||||
continue;
|
||||
}
|
||||
if (!filter && useModern) {
|
||||
if (!isModernModelRef({ provider: model.provider, id: model.id })) {
|
||||
if (!isHighSignalLiveModelRef({ provider: model.provider, id: model.id })) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -417,7 +417,7 @@ describeLive("live models (profile keys)", () => {
|
||||
maxModels > 0 ? maxModels : candidates.length,
|
||||
(entry) => entry.model.provider,
|
||||
);
|
||||
logProgress(`[live-models] selection=${useExplicit ? "explicit" : "modern"}`);
|
||||
logProgress(`[live-models] selection=${useExplicit ? "explicit" : "high-signal"}`);
|
||||
if (selectedCandidates.length < candidates.length) {
|
||||
logProgress(
|
||||
`[live-models] capped to ${selectedCandidates.length}/${candidates.length} via OPENCLAW_LIVE_MAX_MODELS=${maxModels}`,
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
isAnthropicRateLimitError,
|
||||
} from "../agents/live-auth-keys.js";
|
||||
import { isModelNotFoundErrorMessage } from "../agents/live-model-errors.js";
|
||||
import { isModernModelRef } from "../agents/live-model-filter.js";
|
||||
import { isHighSignalLiveModelRef } from "../agents/live-model-filter.js";
|
||||
import { isLiveProfileKeyModeEnabled, isLiveTestEnabled } from "../agents/live-test-helpers.js";
|
||||
import { getApiKeyForModel } from "../agents/model-auth.js";
|
||||
import { normalizeGoogleModelId } from "../agents/model-id-normalization.js";
|
||||
@@ -1503,7 +1503,7 @@ describeLive("gateway live (dev agent, profile keys)", () => {
|
||||
const maxModels = GATEWAY_LIVE_MAX_MODELS;
|
||||
const wanted = filter
|
||||
? all.filter((m) => filter.has(`${m.provider}/${m.id}`))
|
||||
: all.filter((m) => isModernModelRef({ provider: m.provider, id: m.id }));
|
||||
: all.filter((m) => isHighSignalLiveModelRef({ provider: m.provider, id: m.id }));
|
||||
|
||||
const candidates: Array<Model<Api>> = [];
|
||||
const skipped: Array<{ model: string; error: string }> = [];
|
||||
@@ -1544,7 +1544,7 @@ describeLive("gateway live (dev agent, profile keys)", () => {
|
||||
maxModels > 0 ? maxModels : candidates.length,
|
||||
(model) => model.provider,
|
||||
);
|
||||
logProgress(`[all-models] selection=${useExplicit ? "explicit" : "modern"}`);
|
||||
logProgress(`[all-models] selection=${useExplicit ? "explicit" : "high-signal"}`);
|
||||
if (selectedCandidates.length < candidates.length) {
|
||||
logProgress(
|
||||
`[all-models] capped to ${selectedCandidates.length}/${candidates.length} via OPENCLAW_LIVE_GATEWAY_MAX_MODELS=${maxModels}`,
|
||||
|
||||
Reference in New Issue
Block a user