fix: skip image understanding for vision models (#1747)

Thanks @tyler6204.

Co-authored-by: Tyler Yust <64381258+tyler6204@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-01-25 09:56:57 +00:00
parent fdecf5c59a
commit 5f9863098b
3 changed files with 98 additions and 20 deletions

View File

@@ -991,26 +991,6 @@ 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,
@@ -1039,6 +1019,42 @@ 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.
const activeProvider = params.activeModel?.provider?.trim();
if (capability === "image" && activeProvider) {
const catalog = await loadModelCatalog({ config: cfg });
const entry = findModelInCatalog(catalog, activeProvider, params.activeModel?.model ?? "");
if (modelSupportsVision(entry)) {
if (shouldLogVerbose()) {
logVerbose("Skipping image understanding: primary model supports vision natively");
}
const model = params.activeModel?.model?.trim();
const reason = "primary model supports vision natively";
return {
outputs: [],
decision: {
capability,
outcome: "skipped",
attachments: selected.map((item) => {
const attempt = {
type: "provider" as const,
provider: activeProvider,
model: model || undefined,
outcome: "skipped" as const,
reason,
};
return {
attachmentIndex: item.index,
attempts: [attempt],
chosen: attempt,
};
}),
},
};
}
}
const entries = resolveModelEntries({
cfg,
capability,