fix: skip image understanding when primary model has vision
When the primary model supports vision natively (e.g., Claude Opus 4.5), skip the image understanding call entirely. The image will be injected directly into the model context instead, saving an API call and avoiding redundant descriptions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
83f92e34af
commit
fdecf5c59a
@@ -4,6 +4,11 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import {
|
||||
findModelInCatalog,
|
||||
loadModelCatalog,
|
||||
modelSupportsVision,
|
||||
} from "../agents/model-catalog.js";
|
||||
import type { MsgContext } from "../auto-reply/templating.js";
|
||||
import { applyTemplate } from "../auto-reply/templating.js";
|
||||
import { requireApiKey, resolveApiKeyForProvider } from "../agents/model-auth.js";
|
||||
@@ -986,6 +991,26 @@ export async function runCapability(params: {
|
||||
};
|
||||
}
|
||||
|
||||
// Skip image understanding when the primary model supports vision natively.
|
||||
// The image will be injected directly into the model context instead.
|
||||
if (capability === "image" && params.activeModel?.provider) {
|
||||
const catalog = await loadModelCatalog({ config: cfg });
|
||||
const entry = findModelInCatalog(
|
||||
catalog,
|
||||
params.activeModel.provider,
|
||||
params.activeModel.model ?? "",
|
||||
);
|
||||
if (modelSupportsVision(entry)) {
|
||||
if (shouldLogVerbose()) {
|
||||
logVerbose("Skipping image understanding: primary model supports vision natively");
|
||||
}
|
||||
return {
|
||||
outputs: [],
|
||||
decision: { capability, outcome: "skipped", attachments: [] },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const attachmentPolicy = config?.attachments;
|
||||
const selected = selectAttachments({
|
||||
capability,
|
||||
|
||||
Reference in New Issue
Block a user