fix(prometheus): respect fallback chain when no explicit model configured

Previously, Prometheus always used params.currentModel (UI-selected model)
when no explicit configuration existed. This bypassed the intended fallback
chain (claude-opus-4-6 → gpt-5.4 → glm-5 → gemini-3.1-pro).

Now, the UI-selected model is only used if it matches one of the models
in Prometheus's fallback chain. Otherwise, the fallback chain resolution
takes over and finds an available model.

Fixes #2986
This commit is contained in:
YeonGyu-Kim
2026-04-02 13:32:00 +09:00
parent 51d9685571
commit 680bd682c7
2 changed files with 258 additions and 1 deletions
@@ -2,6 +2,7 @@ import type { CategoryConfig } from "../config/schema";
import { PROMETHEUS_PERMISSION, getPrometheusPrompt } from "../agents/prometheus";
import { resolvePromptAppend } from "../agents/builtin-agents/resolve-file-uri";
import { AGENT_MODEL_REQUIREMENTS } from "../shared/model-requirements";
import type { FallbackEntry } from "../shared/model-requirements";
import {
fetchAvailableModels,
readConnectedProvidersCache,
@@ -22,6 +23,20 @@ type PrometheusOverride = Record<string, unknown> & {
prompt_append?: string;
};
function isModelInFallbackChain(
model: string | undefined,
fallbackChain: FallbackEntry[] | undefined,
): boolean {
if (!model || !fallbackChain || fallbackChain.length === 0) {
return false;
}
const modelParts = model.split("/");
const modelName = modelParts.length >= 2 ? modelParts.slice(1).join("/") : model;
return fallbackChain.some((entry) => entry.model === modelName);
}
export async function buildPrometheusAgentConfig(params: {
configAgentPlan: Record<string, unknown> | undefined;
pluginPrometheusOverride: PrometheusOverride | undefined;
@@ -42,9 +57,18 @@ export async function buildPrometheusAgentConfig(params: {
const configuredPrometheusModel =
params.pluginPrometheusOverride?.model ?? categoryConfig?.model;
const shouldUseCurrentModel = isModelInFallbackChain(
params.currentModel,
requirement?.fallbackChain,
);
const modelResolution = resolveModelPipeline({
intent: {
uiSelectedModel: configuredPrometheusModel ? undefined : params.currentModel,
uiSelectedModel: configuredPrometheusModel
? undefined
: shouldUseCurrentModel
? params.currentModel
: undefined,
userModel: params.pluginPrometheusOverride?.model,
categoryDefaultModel: categoryConfig?.model,
},