feat(proxy): add model name prefix stripping option (#568)

Add stripModelPrefix boolean setting that, when enabled, strips
provider prefixes (e.g. openai/, anthropic/) from incoming model
names and re-resolves the bare model name using existing heuristics.

This allows tools to send prefixed model names while OmniRoute
handles provider routing at the proxy layer.

- Add stripModelPrefix to settings validation schema (Zod)
- Check setting in getModelInfo() after custom node matching fails
- Falls through to normal resolution on error or when disabled
- Backward compatible: opt-in, default behavior unchanged
This commit is contained in:
jay77721
2026-03-24 21:40:33 +08:00
parent 6f9f1aec65
commit 18a3741fc2
2 changed files with 15 additions and 0 deletions

View File

@@ -42,6 +42,8 @@ export const updateSettingsSchema = z.object({
a2aEnabled: z.boolean().optional(),
// CLI Fingerprint compatibility (per-provider)
cliCompatProviders: z.array(z.string().max(100)).optional(),
// Strip provider/model prefix at proxy layer (e.g. "openai/gpt-4" → "gpt-4")
stripModelPrefix: z.boolean().optional(),
// Custom CLI agent definitions for ACP
customAgents: z
.array(

View File

@@ -1,5 +1,6 @@
// Re-export from open-sse with localDb integration
import { getModelAliases, getComboByName, getProviderNodes, getCustomModels } from "@/lib/localDb";
import { getSettings } from "@/lib/localDb";
import {
parseModel,
resolveModelAliasFromMap,
@@ -77,6 +78,18 @@ export async function getModelInfo(modelStr) {
...(apiFormat && { apiFormat }),
};
}
// stripModelPrefix: if enabled, strip provider prefix and re-resolve
// the bare model name using existing heuristics (claude-* → anthropic, etc.)
try {
const settings = await getSettings();
if (settings.stripModelPrefix === true) {
const strippedResult = await getModelInfoCore(parsed.model, getModelAliases);
return { ...strippedResult, extendedContext };
}
} catch {
// If settings read fails, fall through to normal resolution
}
}
if (!parsed.isAlias) {