From 6f17533041a61973fa3b248b25e612de67d37170 Mon Sep 17 00:00:00 2001 From: can1357 Date: Sat, 20 Jun 2026 21:48:44 +0200 Subject: [PATCH] fix(tiny): keep `tiny-models download all` green by skipping load-blocked models resolveModels("all") expanded the full TINY_LOCAL_MODELS registry, which now includes the qwen3-1.7b entry marked unsupportedReason. loadPipeline() throws for such specs, so the download worker reported it as failed and the bulk command exited with "One or more tiny title models failed to download" even when every usable model downloaded. Filter unsupported specs out of the `all` prefetch path; explicit single-model requests are unchanged. Addresses the unaddressed Codex P2 on PR #3133. --- .../coding-agent/src/cli/tiny-models-cli.ts | 6 +++-- .../coding-agent/test/tiny-models-cli.test.ts | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 packages/coding-agent/test/tiny-models-cli.test.ts diff --git a/packages/coding-agent/src/cli/tiny-models-cli.ts b/packages/coding-agent/src/cli/tiny-models-cli.ts index 63e534880..ce7f29009 100644 --- a/packages/coding-agent/src/cli/tiny-models-cli.ts +++ b/packages/coding-agent/src/cli/tiny-models-cli.ts @@ -34,9 +34,11 @@ function writeLine(text = ""): void { process.stdout.write(`${text}\n`); } -function resolveModels(model: string | undefined): TinyLocalModelKey[] { +export function resolveModels(model: string | undefined): TinyLocalModelKey[] { if (!model) return [DEFAULT_TINY_TITLE_LOCAL_MODEL_KEY]; - if (model === "all") return TINY_LOCAL_MODELS.map(spec => spec.key); + // `all` is a prefetch convenience: skip models that fail before load (unsupported + // runtime), so the bulk download stays green when every *usable* model succeeds. + if (model === "all") return TINY_LOCAL_MODELS.filter(spec => !spec.unsupportedReason).map(spec => spec.key); if (!isTinyLocalModelKey(model)) { const values = TINY_LOCAL_MODELS.map(spec => spec.key).join(", "); throw new Error(`Unknown tiny local model: ${model}. Expected one of: ${values}, all`); diff --git a/packages/coding-agent/test/tiny-models-cli.test.ts b/packages/coding-agent/test/tiny-models-cli.test.ts new file mode 100644 index 000000000..8cd61a9f3 --- /dev/null +++ b/packages/coding-agent/test/tiny-models-cli.test.ts @@ -0,0 +1,24 @@ +import { describe, expect, it } from "bun:test"; +import { resolveModels } from "@oh-my-pi/pi-coding-agent/cli/tiny-models-cli"; +import { TINY_LOCAL_MODELS } from "@oh-my-pi/pi-coding-agent/tiny/models"; + +describe("tiny-models download model resolution", () => { + it("excludes load-blocked models from `all` so the bulk prefetch stays green", () => { + const unsupported = TINY_LOCAL_MODELS.filter(spec => spec.unsupportedReason).map(spec => spec.key); + // Guard: keep this regression meaningful — at least one registry entry must be load-blocked. + expect(unsupported.length).toBeGreaterThan(0); + + const all = resolveModels("all"); + for (const key of unsupported) expect(all).not.toContain(key); + + const usable = TINY_LOCAL_MODELS.filter(spec => !spec.unsupportedReason).map(spec => spec.key); + for (const key of usable) expect(all).toContain(key); + }); + + it("still resolves an explicitly requested unsupported model (only `all` is filtered)", () => { + const blocked = TINY_LOCAL_MODELS.find(spec => spec.unsupportedReason); + expect(blocked).toBeDefined(); + if (!blocked) return; + expect(resolveModels(blocked.key)).toEqual([blocked.key]); + }); +});