commit 96a0849513e519d6ba18ee2898afb2460d39e2d7
parent 36586fa43bf6933e248839420813016304f9fbe4
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 19 Oct 2026 15:50:45 -0400
clips: a local model labels at most 20 proposals a call; an Ask finds umtool through lane A's umtoolUrl
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/common/controller/clipsSuggest.ts b/common/controller/clipsSuggest.ts
@@ -48,20 +48,14 @@ import {
} from "../lib/report/draft/tasks/clipsSuggest";
import type { AskProposal } from "../lib/clips/suggest.mjs";
import { getWorkerToken } from "../lib/workerToken";
+import { umtoolUrl } from "../lib/umtoolUrl";
import { appendGenerationUsage, dailyCapRefusal, dayUsage, utcDay, type GenerationUsageRow } from "./generationUsage";
import { REPORT_DRAFT_JOB_KIND, REPORT_DRAFT_RESULT_MARKER, llmConfigOf, modelFor, type ReportDraftBody, type ReportDraftDeps, type ReportDraftEnqueued } from "./reportDraft";
export { CLIPS_SUGGEST_TASK, CODE_MODEL };
-/**
- * Where umtool is, for an Ask's reply: `UMTOOL_URL`, trailing slashes dropped;
- * null when unset. (Release 36 lane A adds the shared reader,
- * common/lib/umtoolUrl.ts; this is its rule without the e2e file.)
- */
-export function umtoolOrigin(env: Readonly<Record<string, string | undefined>> = process.env): string | null {
- const url = env.UMTOOL_URL?.trim().replace(/\/+$/, "");
- return url ? url : null;
-}
+/** Where umtool is, for an Ask's reply: `UMTOOL_URL` (lane A's reader, common/lib/umtoolUrl.ts); null when unset. */
+export const umtoolOrigin = (env: Readonly<Record<string, string | undefined>> = process.env): string | null => umtoolUrl(env);
export type ClipsSuggestJobDeps = ReportDraftDeps & {
// An Ask's reply, posted (default: umtool's /api/notes over HTTP).
diff --git a/common/lib/report/draft/tasks/clipsSuggest.test.ts b/common/lib/report/draft/tasks/clipsSuggest.test.ts
@@ -0,0 +1,25 @@
+// Release 36 lane D: how a labels pass batches the proposals.
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { batchesOf, LOCAL_BATCH_MAX } from "./clipsSuggest";
+import type { SuggestInput } from "../../../clips/suggest.mjs";
+
+const items = (n: number, words = 20): SuggestInput[] =>
+ Array.from({ length: n }, (_, i) => ({
+ id: `p${String(i + 1).padStart(3, "0")}`,
+ start: i * 30,
+ end: i * 30 + 12,
+ score: 0.5,
+ used: false,
+ kinds: ["laugh"],
+ lines: [{ role: "host", speaker: 0, text: Array.from({ length: words }, (_, k) => `w${k}`).join(" ") }],
+ }));
+
+test("batches: 30 a call on the API; at most 20 locally, and fewer when the prompt cap is reached", () => {
+ assert.deepEqual(batchesOf(items(70), "claude-sonnet-5-5").map((b) => b.length), [30, 30, 10]);
+ assert.equal(LOCAL_BATCH_MAX, 20);
+ assert.deepEqual(batchesOf(items(45), "qwen3:8b").map((b) => b.length), [20, 20, 5]);
+ const long = batchesOf(items(45, 600), "qwen3:8b");
+ assert.ok(long.length > 3 && long.every((b) => b.length >= 1 && b.length < 20), JSON.stringify(long.map((b) => b.length)));
+ assert.deepEqual(long.flat().map((i) => i.id), items(45).map((i) => i.id));
+});
diff --git a/common/lib/report/draft/tasks/clipsSuggest.ts b/common/lib/report/draft/tasks/clipsSuggest.ts
@@ -62,6 +62,8 @@ export const CLIPS_SUGGEST_TASK = "clips-suggest" as const;
export const CODE_MODEL = "claude-code";
const LOCAL_CAP = PROMPT_CAP_TOKENS - 400;
const ANSWER_TOKENS_PER_ITEM = 60;
+// A local model answers at most this many in one call (an 8B model loses ids in a long list).
+export const LOCAL_BATCH_MAX = 20;
const ASK_ANSWER_TOKENS = 500;
export class ClipsSuggestRefusal extends Error {}
@@ -99,7 +101,7 @@ export async function loadClipsProject(dir: string, deps: Pick<ClipsSuggestDeps,
return { dir, reactions, words: wordsFor({ cues: cues ? [...cues] : [] }), wordsFrom: cues?.length ? "cues" : "none" };
}
-/** The batches a model is asked in: SUGGEST_API_BATCH on the API, fitted to the prompt cap on a local model. */
+/** The batches a model is asked in: SUGGEST_API_BATCH on the API; on a local model at most LOCAL_BATCH_MAX, fitted to the prompt cap. */
export function batchesOf(items: SuggestInput[], model: string, localCap = LOCAL_CAP): SuggestInput[][] {
const out: SuggestInput[][] = [];
if (providerOf(model) === "api") {
@@ -109,7 +111,7 @@ export function batchesOf(items: SuggestInput[], model: string, localCap = LOCAL
let cur: SuggestInput[] = [];
for (const it of items) {
const next = [...cur, it];
- if (cur.length && structuredPromptEstimate({ ...suggestPrompt(next), schema: SUGGEST_ANSWER_SCHEMA }) > localCap) {
+ if (cur.length && (cur.length >= LOCAL_BATCH_MAX || structuredPromptEstimate({ ...suggestPrompt(next), schema: SUGGEST_ANSWER_SCHEMA }) > localCap)) {
out.push(cur);
cur = [it];
} else cur = next;