Skip to content

Commit f408914

Browse files
committed
fix(cli): give noVisionModels precedence over an exact modality entry
isModelTextOnly returns true on the noVisionModels match before it ever reads modelInputModalities, so a `gpt-oss` noVision entry beats an exact `gpt-oss:120b` entry that lists "image". Resolving the exact entry first made `ocx models` advertise image support the proxy then rejects — the same class of drift this PR set out to remove. Add the conflicting-config regression case, which asserts the runtime's answer via isModelTextOnly before comparing the CLI's. Thanks @coderabbitai for catching it.
1 parent 71ed29d commit f408914

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

‎src/cli/models.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,11 @@ function collectModels(config: OcxConfig, providerFilter?: string): ModelEntry[]
102102
// proxy will not honour: `isModelTextOnly` matches noVisionModels with modelInList
103103
// and reads modelInputModalities with modelRecordValue, so a `gpt-oss` entry covers
104104
// `gpt-oss:120b`. A bare lookup reported that model as unclassified on every field.
105+
// noVisionModels is checked first because `isModelTextOnly` returns true on that
106+
// match before it ever reads modelInputModalities: a `gpt-oss` noVision entry beats
107+
// an exact `gpt-oss:120b` entry that lists "image", and the proxy rejects the image.
105108
const noVision = modelInList(prov.noVisionModels, model);
106-
const modalities = modelRecordValue(inputModalities, model) ?? (noVision ? ["text"] : null);
109+
const modalities = noVision ? ["text"] : (modelRecordValue(inputModalities, model) ?? null);
107110
const efforts = modelRecordValue(reasoningEfforts, model) ?? prov.reasoningEfforts ?? null;
108111

109112
entries.push({

‎tests/cli-models.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,39 @@ describe("ocx models richer metadata", () => {
203203
}
204204
});
205205

206+
test("a noVision family entry beats an exact modality entry, as the runtime does", () => {
207+
// isModelTextOnly returns true on the noVisionModels match before it ever reads
208+
// modelInputModalities, so an exact entry listing "image" does not grant vision.
209+
// Reporting ["text", "image"] here would advertise support the proxy then rejects.
210+
const dir = mkdtempSync(join(tmpdir(), "ocx-models-novision-"));
211+
const provider = {
212+
adapter: "openai-chat",
213+
baseUrl: "http://localhost:8080/v1",
214+
allowPrivateNetwork: true,
215+
defaultModel: "gpt-oss:120b",
216+
models: ["gpt-oss:120b"],
217+
noVisionModels: ["gpt-oss"],
218+
modelInputModalities: { "gpt-oss:120b": ["text", "image"] },
219+
};
220+
writeFileSync(
221+
join(dir, "config.json"),
222+
JSON.stringify({ port: 10123, providers: { test: provider }, defaultProvider: "test" }),
223+
"utf8",
224+
);
225+
try {
226+
// Ground truth first: the proxy treats this model as text-only.
227+
expect(isModelTextOnly(provider as unknown as OcxProviderConfig, "gpt-oss:120b")).toBe(true);
228+
229+
const result = runCli(["models", "--json"], { OPENCODEX_HOME: dir });
230+
expect(result.status).toBe(0);
231+
const row = JSON.parse(result.stdout).models
232+
.find((m: { model: string }) => m.model === "gpt-oss:120b");
233+
expect(row.inputModalities).toEqual(["text"]);
234+
} finally {
235+
rmSync(dir, { recursive: true, force: true });
236+
}
237+
});
238+
206239
test("an exact entry still wins over the family entry", () => {
207240
const dir = mkdtempSync(join(tmpdir(), "ocx-models-exact-"));
208241
const provider = {

0 commit comments

Comments
 (0)