mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-08 06:54:24 +00:00
fix: wire agents.defaults.imageModel into media understanding auto-discovery
resolveAutoEntries only checked a hardcoded list of providers
(openai, anthropic, google, minimax) when looking for an image model.
agents.defaults.imageModel was never consulted by the media understanding
pipeline — it was only wired into the explicit `image` tool.
Add resolveImageModelFromAgentDefaults that reads the imageModel config
(primary + fallbacks) and inserts it into the auto-discovery chain before
the hardcoded provider list. runProviderEntry already falls back to
describeImageWithModel (via pi-ai) for providers not in the media
understanding registry, so no additional provider registration is needed.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
(cherry picked from commit b381029ede)
This commit is contained in:
committed by
Peter Steinberger
parent
ae2c8f2cf0
commit
5acec7f79b
@@ -391,6 +391,44 @@ async function resolveKeyEntry(params: {
|
||||
return null;
|
||||
}
|
||||
|
||||
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 entries: MediaUnderstandingModelConfig[] = [];
|
||||
for (const ref of refs) {
|
||||
const slashIdx = ref.indexOf("/");
|
||||
if (slashIdx <= 0 || slashIdx >= ref.length - 1) {
|
||||
continue;
|
||||
}
|
||||
entries.push({
|
||||
type: "provider",
|
||||
provider: ref.slice(0, slashIdx),
|
||||
model: ref.slice(slashIdx + 1),
|
||||
});
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
async function resolveAutoEntries(params: {
|
||||
cfg: OpenClawConfig;
|
||||
agentDir?: string;
|
||||
@@ -408,6 +446,12 @@ async function resolveAutoEntries(params: {
|
||||
return [localAudio];
|
||||
}
|
||||
}
|
||||
if (params.capability === "image") {
|
||||
const imageModelEntries = resolveImageModelFromAgentDefaults(params.cfg);
|
||||
if (imageModelEntries.length > 0) {
|
||||
return imageModelEntries;
|
||||
}
|
||||
}
|
||||
const gemini = await resolveGeminiCliEntry(params.capability);
|
||||
if (gemini) {
|
||||
return [gemini];
|
||||
|
||||
Reference in New Issue
Block a user