Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit a4f1411a5ab8cb4ee58a997e56d79bd8cb3f48d2
parent 66ce7a07d8e07641b1e12755e9d49293f95d29bc
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 13 Oct 2026 15:08:37 -0400

common: a revision whose model never calls apply_ops gets one schema-bound ask for the batch; none at all is a failing ops check

Found in the release 27 live smoke: qwen3:8b read the report, then ended its turn empty, and the
revision was "done, 0 applied". A format/strict-tool answer is what the local model does reliably.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mcommon/lib/report/draft/tasks/revise-report.ts | 28+++++++++++++++++++++++++++-
Mcommon/lib/report/draft/tasks/revise-video.ts | 28+++++++++++++++++++++++++++-
Mmcp/src/draftTasks.test.ts | 24+++++++++++++++++++++++-
3 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/common/lib/report/draft/tasks/revise-report.ts b/common/lib/report/draft/tasks/revise-report.ts @@ -9,7 +9,7 @@ // Then the link backstop, convert and the quote check: a NEW finding whose // quote fails is dropped, never repaired. -import { providerOf, runAgent, type AgentTool } from "../../../llm"; +import { providerOf, runAgent, structuredAnswer, type AgentTool } from "../../../llm"; import { lineage, readIterationFile, writeIterationFile } from "../../iterations"; import { CLAIM_QUOTES_RULE, UNATTENDED_RULE, VERBATIM_QUOTES_RULE, momentLinkRule } from "../authoringRules"; import { applyReportOps, strictCheckerOver, type AppliedOp, type RefusedOp } from "../reportOps"; @@ -189,6 +189,32 @@ async function reviseReportBody(h: TaskHandle, input: ReviseReportInput): Promis }); h.turns(run.transcript); if (run.stopReason === "cancelled") return { status: "failed", summary: "cancelled" }; + // A model that ends without calling apply_ops (a local model's tool call often + // comes back empty) gets ONE schema-bound ask for the batch; nothing at all + // after that is a failing check, not a quiet "0 applied". + if (applied.length + refused.length === 0) { + const asked = await structuredAnswer<{ ops?: unknown[] }>({ + llm: deps.llm, + model, + system, + user: `OPERATOR FEEDBACK:\n${feedback}\n\nTHE REPORT NOW:\n${numberedView(doc)}\n\nAnswer with the ops batch that carries out the feedback.`, + schema: OPS_SCHEMA, + meter: h.meter, + signal: deps.signal, + }).catch((e: unknown) => { + h.log(`the ops ask failed: ${(e as Error).message}`); + return null; + }); + if (asked && Array.isArray(asked.ops) && asked.ops.length) { + h.log(`no apply_ops call: asked for the batch, ${asked.ops.length} op(s)`); + await tools.find((t) => t.name === "apply_ops")!.run({ ops: asked.ops }, { signal: deps.signal }); + } + } + h.check({ + name: "ops", + ok: applied.length + refused.length > 0, + detail: applied.length + refused.length > 0 ? `${applied.length} applied, ${refused.length} refused` : "the model proposed no edits", + }); let md = renderSweep(doc); const fixed = await rewriteLinks(md, resolver, origin); diff --git a/common/lib/report/draft/tasks/revise-video.ts b/common/lib/report/draft/tasks/revise-video.ts @@ -9,7 +9,7 @@ // and stills copied, the voices hard-linked. A video revision has no report of // its own (its article's report stays its nearest ancestor's). -import { providerOf, runAgent, type AgentTool } from "../../../llm"; +import { providerOf, runAgent, structuredAnswer, type AgentTool } from "../../../llm"; import { readIteration, type Iteration } from "../../iterations"; import { applyVideoOps, cutView, type AppliedVideoOp, type RefusedVideoOp, type ReportForVideo, type VideoManifest } from "../videoOps"; import { rewriteMomentBases, slugResolver } from "./links"; @@ -125,6 +125,32 @@ async function reviseVideoBody(h: TaskHandle, input: ReviseVideoInput): Promise< }); h.turns(run.transcript); if (run.stopReason === "cancelled") return { status: "failed", summary: "cancelled" }; + // A model that ends without calling apply_ops (a local model's tool call often + // comes back empty) gets ONE schema-bound ask for the batch; nothing at all + // after that is a failing check, not a quiet "0 applied". + if (applied.length + refused.length === 0) { + const asked = await structuredAnswer<{ ops?: unknown[] }>({ + llm: deps.llm, + model, + system, + user: `OPERATOR FEEDBACK:\n${feedback}\n\nTHE VIDEO NOW:\n${view()}\n\nAnswer with the ops batch that carries out the feedback.`, + schema: OPS_SCHEMA, + meter: h.meter, + signal: deps.signal, + }).catch((e: unknown) => { + h.log(`the ops ask failed: ${(e as Error).message}`); + return null; + }); + if (asked && Array.isArray(asked.ops) && asked.ops.length) { + h.log(`no apply_ops call: asked for the batch, ${asked.ops.length} op(s)`); + await tools.find((t) => t.name === "apply_ops")!.run({ ops: asked.ops }, { signal: deps.signal }); + } + } + h.check({ + name: "ops", + ok: applied.length + refused.length > 0, + detail: applied.length + refused.length > 0 ? `${applied.length} applied, ${refused.length} refused` : "the model proposed no edits", + }); const ops = { applied: applied.map((a) => (a.warnings ? { ...a.op, warnings: a.warnings } : a.op)), diff --git a/mcp/src/draftTasks.test.ts b/mcp/src/draftTasks.test.ts @@ -12,7 +12,7 @@ import os from "node:os"; import path from "node:path"; import { CHANNELS, POSTS, ORIGIN, cuesOf, writeDraftCorpus } from "yt-dlp-transcript-common/testing/draft/corpus.mjs"; import { FAKE_KEY, startFakeAnthropic, textTurn, type FakeAnthropic } from "yt-dlp-transcript-common/testing/llm/fakeAnthropic.mjs"; -import { startFakeOllama, type FakeOllama } from "yt-dlp-transcript-common/testing/llm/fakeOllama.mjs"; +import { jsonReply, reply, startFakeOllama, toolCallsReply, type FakeOllama } from "yt-dlp-transcript-common/testing/llm/fakeOllama.mjs"; import { createIteration, readIteration, @@ -329,3 +329,25 @@ test("a task refuses an iteration that is not its own or not queued", async () = ); assert.ok(CHANNELS.length > 0); }); + +test("revise-report on a local model that never calls apply_ops: one schema-bound ask for the batch, then the check says so", async () => { + await drainFake(); + await doneSweep("synth-basic", "basic"); + const it = await createIteration("synth-basic", { kind: "revise-report", model: "qwen3:8b", parent: 1, feedback: "Drop the mixer finding." }, paths); + // read_doc, then an empty answer (no tool call); then the ask answers with the batch. + ol.push(toolCallsReply([{ name: "read_doc", arguments: {} }]), reply(""), jsonReply({ ops: [{ op: "drop", n: 3 }] })); + const d = deps(); + const out = await runTask({ task: "revise-report", article: "synth-basic", n: it.n, origin: ORIGIN, maxUsd: 1 }, d); + assert.equal(out.status, "done", `${out.summary}\n${d.lines.join("\n")}`); + const after = (await readIteration("synth-basic", it.n, paths))!; + assert.deepEqual((after.ops!.applied as { op: string }[]).map((o) => o.op), ["drop"]); + assert.ok(after.checks!.some((c) => c.name === "ops" && c.ok)); + assert.ok(!(await readIterationFile("synth-basic", it.n, "sweep.md", paths))!.includes("new mixer")); + + // A model that proposes nothing even then: done, with a failing ops check. + const it2 = await createIteration("synth-basic", { kind: "revise-report", model: "qwen3:8b", parent: 1, feedback: "Drop the mixer finding." }, paths); + ol.push(reply(""), jsonReply({ ops: [] })); + await runTask({ task: "revise-report", article: "synth-basic", n: it2.n, origin: ORIGIN, maxUsd: 1 }, deps()); + const after2 = (await readIteration("synth-basic", it2.n, paths))!; + assert.ok(after2.checks!.some((c) => c.name === "ops" && !c.ok && /no edits/.test(String(c.detail)))); +});