fix: Atlas respects fallbackChain, always refresh provider-models cache

- Remove uiSelectedModel from Atlas model resolution (use k2p5 as primary)
- Always overwrite provider-models.json on session start to prevent stale cache
This commit is contained in:
justsisyphus 2026-01-30 16:14:14 +09:00
parent 3074434887
commit 1187a02020
2 changed files with 12 additions and 10 deletions

View File

@ -329,7 +329,7 @@ export async function createBuiltinAgents(
const atlasRequirement = AGENT_MODEL_REQUIREMENTS["atlas"] const atlasRequirement = AGENT_MODEL_REQUIREMENTS["atlas"]
const atlasResolution = resolveModelWithFallback({ const atlasResolution = resolveModelWithFallback({
uiSelectedModel, // NOTE: Atlas does NOT use uiSelectedModel - respects its own fallbackChain (k2p5 primary)
userModel: orchestratorOverride?.model, userModel: orchestratorOverride?.model,
fallbackChain: atlasRequirement?.fallbackChain, fallbackChain: atlasRequirement?.fallbackChain,
availableModels, availableModels,

View File

@ -159,13 +159,13 @@ export async function updateConnectedProvidersCache(client: {
writeConnectedProvidersCache(connected) writeConnectedProvidersCache(connected)
// Also update provider-models cache if model.list is available // Always update provider-models cache (overwrite with fresh data)
let modelsByProvider: Record<string, string[]> = {}
if (client.model?.list) { if (client.model?.list) {
try { try {
const modelsResult = await client.model.list() const modelsResult = await client.model.list()
const models = modelsResult.data ?? [] const models = modelsResult.data ?? []
const modelsByProvider: Record<string, string[]> = {}
for (const model of models) { for (const model of models) {
if (!modelsByProvider[model.provider]) { if (!modelsByProvider[model.provider]) {
modelsByProvider[model.provider] = [] modelsByProvider[model.provider] = []
@ -173,19 +173,21 @@ export async function updateConnectedProvidersCache(client: {
modelsByProvider[model.provider].push(model.id) modelsByProvider[model.provider].push(model.id)
} }
writeProviderModelsCache({ log("[connected-providers-cache] Fetched models from API", {
models: modelsByProvider,
connected,
})
log("[connected-providers-cache] Provider-models cache updated", {
providerCount: Object.keys(modelsByProvider).length, providerCount: Object.keys(modelsByProvider).length,
totalModels: models.length, totalModels: models.length,
}) })
} catch (modelErr) { } catch (modelErr) {
log("[connected-providers-cache] Error fetching models", { error: String(modelErr) }) log("[connected-providers-cache] Error fetching models, writing empty cache", { error: String(modelErr) })
} }
} else {
log("[connected-providers-cache] client.model.list not available, writing empty cache")
} }
writeProviderModelsCache({
models: modelsByProvider,
connected,
})
} catch (err) { } catch (err) {
log("[connected-providers-cache] Error updating cache", { error: String(err) }) log("[connected-providers-cache] Error updating cache", { error: String(err) })
} }