fix: preserve provider prefix in cron model suggestions

The Control UI cron model field suggestions were built using only the
model ID (e.g. "gpt-oss:120b-cloud") without the provider prefix
(e.g. "ollama/"). When a user selected such a suggestion, the server
would fall back to the session's default provider (typically "anthropic"),
producing an error like:

  Failed to set model: model not allowed: anthropic/gpt-oss:120b-cloud

Fix loadCronModelSuggestions to include the provider prefix in each
suggestion so the submitted value is fully qualified (e.g.
"ollama/gpt-oss:120b-cloud"), matching the same format used by the
chat session model picker.

Fixes openclaw/openclaw#51306
This commit is contained in:
Albert 2026-03-21 10:18:13 +08:00
parent e84266e520
commit 0deb67f273

View File

@ -203,8 +203,13 @@ export async function loadCronModelSuggestions(state: CronModelSuggestionsState)
if (!entry || typeof entry !== "object") {
return "";
}
const id = (entry as { id?: unknown }).id;
return typeof id === "string" ? id.trim() : "";
const { id, provider } = entry as { id?: unknown; provider?: unknown };
const modelId = typeof id === "string" ? id.trim() : "";
if (!modelId) {
return "";
}
const modelProvider = typeof provider === "string" ? provider.trim() : "";
return modelProvider ? `${modelProvider}/${modelId}` : modelId;
})
.filter(Boolean);
state.cronModelSuggestions = Array.from(new Set(ids)).toSorted((a, b) => a.localeCompare(b));