mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 00:13:28 +00:00
fix(agents): fall back to agents.defaults.model when agent has no model config (#24210)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 0f272b1027
Co-authored-by: bianbiandashen <16240681+bianbiandashen@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -10,6 +10,10 @@ import {
|
||||
} from "../agents/model-catalog.js";
|
||||
import type { MsgContext } from "../auto-reply/templating.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import {
|
||||
resolveAgentModelFallbackValues,
|
||||
resolveAgentModelPrimaryValue,
|
||||
} from "../config/model-input.js";
|
||||
import type {
|
||||
MediaUnderstandingConfig,
|
||||
MediaUnderstandingModelConfig,
|
||||
@@ -418,28 +422,19 @@ async function resolveKeyEntry(params: {
|
||||
}
|
||||
|
||||
function resolveImageModelFromAgentDefaults(cfg: OpenClawConfig): MediaUnderstandingModelConfig[] {
|
||||
const imageModel = cfg.agents?.defaults?.imageModel as
|
||||
| { primary?: string; fallbacks?: string[] }
|
||||
| string
|
||||
| undefined;
|
||||
if (!imageModel) {
|
||||
return [];
|
||||
}
|
||||
const refs: string[] = [];
|
||||
if (typeof imageModel === "string") {
|
||||
if (imageModel.trim()) {
|
||||
refs.push(imageModel.trim());
|
||||
}
|
||||
} else {
|
||||
if (imageModel.primary?.trim()) {
|
||||
refs.push(imageModel.primary.trim());
|
||||
}
|
||||
for (const fb of imageModel.fallbacks ?? []) {
|
||||
if (fb?.trim()) {
|
||||
refs.push(fb.trim());
|
||||
}
|
||||
const primary = resolveAgentModelPrimaryValue(cfg.agents?.defaults?.imageModel);
|
||||
if (primary?.trim()) {
|
||||
refs.push(primary.trim());
|
||||
}
|
||||
for (const fb of resolveAgentModelFallbackValues(cfg.agents?.defaults?.imageModel)) {
|
||||
if (fb?.trim()) {
|
||||
refs.push(fb.trim());
|
||||
}
|
||||
}
|
||||
if (refs.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const entries: MediaUnderstandingModelConfig[] = [];
|
||||
for (const ref of refs) {
|
||||
const slashIdx = ref.indexOf("/");
|
||||
|
||||
Reference in New Issue
Block a user