Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
treat an empty vision reply as a caption failure, not a trigger-word-only caption
[._.]/ Adam Eivy66ac040ee33e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 48e2a04b0d..3c41b018d8 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -12,6 +12,8 @@## Fixed+- **LoRA auto-captions no longer silently come back as just the trigger word** — When a vision model returned an empty reply (common when it refuses a realistic close-up face, or when a thinking model spends its whole token budget reasoning), the captioner prefixed that empty string with the trigger word and saved the result — so the image was bound but undescribed, yet the run still logged it as captioned. A blank model reply is now treated as a per-image failure: it's surfaced in the caption run's progress (with the model name and a hint to try a different vision model or caption manually) and never persisted, so the image stays un-captioned and a re-run re-attempts it instead of leaving a degenerate trigger-word-only caption. (`server/services/loraDatasetCaption.js`)+- **LoRA caption-model picker now sees vision-capable Ollama models whose name lacks a `vl`/`vision` token** — The picker showed "none installed" even with a vision model like the `qwen3.6:35b` MoE installed, because Ollama's `/api/tags` carries no vision flag and the id heuristic only matches names containing a `vl`/`vision`/known-family token. Ollama *does* report `capabilities: ["…","vision",…]` via `/api/show`, but PortOS only consulted that for LM Studio. `listVisionModels` now enriches each Ollama model the id heuristic doesn't already catch with its `/api/show` capabilities (cached per model, busted on delete), so capability-tagged vision models surface in the picker — and, through the same path, in the captioner's auto-pick and explicit-model validation. (`server/services/ollamaManager.js`, `server/services/localLlm.js`)- **TUI agents no longer leave the prompt sitting unsent in the input box** — CoS agents that run inside a terminal-UI provider (Claude Code, Codex) bracketed-paste their task prompt and then send a single Enter to submit it. On a large multi-line prompt that one `\r` could arrive while the TUI was still reflowing the paste and get swallowed — so the prompt sat typed-but-unsubmitted, the agent did no work, idled out after 3 minutes, and was (wrongly) recorded as a successful run. You'd see it only by opening the Shell tab and hitting Enter yourself. The submit Enter now fires a few times spaced ~700ms apart so one lands after the paste settles; re-sending is safe because once the prompt submits the input box is empty and a bare Enter is a no-op. Applies to both the long-running agent path and the one-shot TUI runner. (`server/lib/tuiHandshake.js`, `server/services/agentTuiSpawning.js`, `server/lib/tuiPromptRunner.js`)diff --git a/server/services/loraDatasetCaption.js b/server/services/loraDatasetCaption.jsindex 5a1b9f3da7..c022ace4a5 100644--- a/server/services/loraDatasetCaption.js+++ b/server/services/loraDatasetCaption.js@@ -107,6 +107,24 @@ export async function resolveCaptionModel({return { providerId: pick.providerId, model: pick.id };}+/**+ * Build the persisted caption from a vision model's raw reply.+ *+ * An empty reply would `prefixCaption` down to just the trigger word — a+ * degenerate "caption" that still counts as success and gets persisted, leaving+ * the image bound but undescribed. Vision models commonly return blank content+ * when they refuse a realistic close-up face (or a thinking model spends its+ * whole token budget reasoning). Throwing here routes blank output through the+ * loop's failure path, so it's surfaced and re-attemptable rather than saved as+ * a trigger-word-only caption.+ */+export function buildCaption(triggerWord, text, model = 'vision model') {+ if (!text || !text.trim()) {+ throw new Error(`${model} returned an empty description — it may have refused this image; try a different vision model or caption it manually`);+ }+ return prefixCaption(triggerWord, text);+}+const emit = (runId, payload) => {const run = captionRuns.get(runId);if (run) broadcastSse(run, payload);@@ -165,7 +183,7 @@ export async function startCaptionRun(datasetId, {model: resolvedModel,maxTokens: CAPTION_MAX_TOKENS,});- caption = prefixCaption(dataset.triggerWord, text);+ caption = buildCaption(dataset.triggerWord, text, `vision model "${resolvedModel}"`);} catch (err) {failed += 1;console.error(`❌ Caption failed [${shortId(runId)} ${img.id}]: ${err?.message || err}`);diff --git a/server/services/loraDatasetCaption.test.js b/server/services/loraDatasetCaption.test.jsindex 02fd1d7712..a6087b9a6c 100644--- a/server/services/loraDatasetCaption.test.js+++ b/server/services/loraDatasetCaption.test.js@@ -4,7 +4,7 @@ import { describe, it, expect, vi } from 'vitest';// branches are testable without touching the network/DB. The module still// pulls in localLlm transitively at import; that's import-only (no calls fire// until resolveCaptionModel runs with our stub), so no mocks are needed.-const { resolveCaptionModel } = await import('./loraDatasetCaption.js');+const { resolveCaptionModel, buildCaption } = await import('./loraDatasetCaption.js');const VISION = [{ providerId: 'lmstudio', backend: 'lmstudio', id: 'qwen2.5-vl-7b', name: 'Qwen2.5-VL 7B', vision: true },@@ -63,3 +63,24 @@ describe('resolveCaptionModel', () => {.rejects.toMatchObject({ status: 409, code: 'LORA_CAPTION_NO_VISION_MODEL' });});});++describe('buildCaption', () => {+ it('prefixes a real description with the trigger word', () => {+ expect(buildCaption('tamsin_reed', 'close-up bust, neutral expression'))+ .toBe('tamsin_reed, close-up bust, neutral expression');+ });++ it('throws on an empty reply instead of returning a trigger-word-only caption', () => {+ // The regression: a blank vision reply must NOT degrade to just the trigger+ // word (which the loop would persist as a bogus "success"). It must fail so+ // the image is surfaced and re-attemptable.+ expect(() => buildCaption('tamsin_reed', '')).toThrow(/empty description/);+ expect(() => buildCaption('tamsin_reed', ' \n ')).toThrow(/empty description/);+ expect(() => buildCaption('tamsin_reed', null)).toThrow(/empty description/);+ });++ it('names the model in the error so the user knows which to swap', () => {+ expect(() => buildCaption('tamsin_reed', '', 'vision model "llava:7b"'))+ .toThrow(/llava:7b/);+ });+});