mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 15:00:41 +00:00
fix(agents): warn clearly on unresolved model ids (#39215, thanks @ademczuk)
Co-authored-by: ademczuk <andrew.demczuk@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resolveAgentModelPrimaryValue, toAgentModelListLike } from "../config/model-input.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { sanitizeForLog } from "../terminal/ansi.js";
|
||||
import { resolveAgentConfig, resolveAgentEffectiveModelPrimary } from "./agent-scope.js";
|
||||
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "./defaults.js";
|
||||
import type { ModelCatalogEntry } from "./model-catalog.js";
|
||||
@@ -302,8 +303,9 @@ export function resolveConfiguredModelRef(params: {
|
||||
}
|
||||
|
||||
// Default to anthropic if no provider is specified, but warn as this is deprecated.
|
||||
const safeTrimmed = sanitizeForLog(trimmed);
|
||||
log.warn(
|
||||
`Model "${trimmed}" specified without provider. Falling back to "anthropic/${trimmed}". Please use "anthropic/${trimmed}" in your config.`,
|
||||
`Model "${safeTrimmed}" specified without provider. Falling back to "anthropic/${safeTrimmed}". Please use "anthropic/${safeTrimmed}" in your config.`,
|
||||
);
|
||||
return { provider: "anthropic", model: trimmed };
|
||||
}
|
||||
@@ -316,6 +318,11 @@ export function resolveConfiguredModelRef(params: {
|
||||
if (resolved) {
|
||||
return resolved.ref;
|
||||
}
|
||||
|
||||
// User specified a model but it could not be resolved — warn before falling back.
|
||||
const safe = sanitizeForLog(trimmed);
|
||||
const safeFallback = sanitizeForLog(`${params.defaultProvider}/${params.defaultModel}`);
|
||||
log.warn(`Model "${safe}" could not be resolved. Falling back to default "${safeFallback}".`);
|
||||
}
|
||||
// Before falling back to the hardcoded default, check if the default provider
|
||||
// is actually available. If it isn't but other providers are configured, prefer
|
||||
|
||||
Reference in New Issue
Block a user