fix(agent): honor configured auto image model for image intents
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-02-20 19:13:15 +08:00
parent 35a65f26f6
commit c91486e1bb

View File

@ -143,17 +143,28 @@ export async function routeToModel(params: {
);
if (configuredModel) {
const isImageIntent = intent === "image_edit" || intent === "image_gen";
const matchesVision = !config.requireVision || configuredModel.model.supportsVision;
const matchesImageGen = !config.requireImageGen || configuredModel.model.supportsImageGen;
const allowImageIntentWithImageGenOnly =
isImageIntent && configuredModel.model.supportsImageGen;
if (matchesVision && matchesImageGen) {
if ((matchesVision && matchesImageGen) || allowImageIntentWithImageGenOnly) {
const reason = allowImageIntentWithImageGenOnly && !matchesVision
? `管理员配置的默认模型(按生图能力优先)→ ${configuredModel.model.displayName}`
: `管理员配置的默认模型 → ${configuredModel.model.displayName}`;
console.log("[Model Router] ✅ Using configured default model:", configuredModel.model.displayName);
if (allowImageIntentWithImageGenOnly && !matchesVision) {
console.log(
"[Model Router] ℹ️ Configured default model does not support vision, but image intent can reuse Agent analysis and keep admin default image model."
);
}
return {
id: configuredModel.model.id,
displayName: configuredModel.model.displayName,
providerType: configuredModel.provider.type,
modelId: configuredModel.model.modelId,
reason: `管理员配置的默认模型 → ${configuredModel.model.displayName}`,
reason,
};
}