Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(workbench): one tool roster, pinned in CI, instead of three hand-written ones

EtienneLescot992cad823ecd
diff --git a/electron/ai-edition/agent-tools.ts b/electron/ai-edition/agent-tools.ts
index 67bf72a9b..e3cd23218 100644
--- a/electron/ai-edition/agent-tools.ts
+++ b/electron/ai-edition/agent-tools.ts
@@ -516,6 +516,80 @@ export const removeClipArgs = z.object({
* documentation duty is `TOOL_DESCRIPTIONS`; `service.test.ts` pins the three
* remaining surfaces (descriptions, built tools, executor cases) to each other.
*/
+/**
+ * Every tool the model is handed, in the order `buildTools` builds them.
+ *
+ * The roster lives here, beside `MUTATING_TOOL_NAMES`, rather than in
+ * `deep-agent/service.ts` where `buildTools` is: the workbench needs to name the
+ * surface from its L0 layer, and importing the service would drag LangChain into
+ * a layer that deliberately runs on zod and pure document helpers alone.
+ *
+ * It is hand-written — the schemas differ per tool, so nothing can generate it —
+ * but it is not free-floating: `deep-agent/service.test.ts` asserts it equals
+ * `buildTools(...).map(t => t.name)`, and that test runs in CI. Adding a tool
+ * without adding it here fails the suite.
+ *
+ * ponytail: there used to be two more copies of this list, one in that test and
+ * one in `workbench/lib/prompts.ts`, neither derived from anything. The
+ * workbench's copy sat at 19 entries from the day it was written while the agent
+ * grew to 21 (`addTrims`/`addZooms`, commit 560d368e). Nothing caught it,
+ * because `npm run wb` is not part of CI — so the bench asserted a surface the
+ * product had not had for some time.
+ */
+export const OPENSCREEN_TOOL_NAMES = [
+ "getCurrentDocument",
+ "getTranscript",
+ "getCursorTrack",
+ "addTrim",
+ "addTrims",
+ "setTrim",
+ "setClipRange",
+ "moveClip",
+ "replaceTimeline",
+ "addZoom",
+ "addZooms",
+ "setZoom",
+ "addSpeed",
+ "setSpeed",
+ "addAnnotation",
+ "setAnnotation",
+ "addCameraFullscreen",
+ "setCameraFullscreen",
+ "removeTrim",
+ "removeModifier",
+ "removeClip",
+] as const;
+
+/**
+ * The tools `createDeepAgent` used to inject on top of ours, over an in-memory
+ * backend that was EMPTY and that the model was not told was empty — the
+ * mechanical cause of D1, where the agent ran `ls`/`glob` against that sandbox
+ * and reported in good faith that the project held no cursor telemetry.
+ *
+ * The surface is gone, so this is no longer "tools we also get": it is the list
+ * of names that must never appear again. A call to one of them now means the
+ * model is hallucinating a filesystem it was never offered, which is a rarer but
+ * still exact D1 tell — which is why the workbench scores it as well as pinning
+ * it here.
+ *
+ * `execute` is included even though it vanished at runtime: it is in the
+ * middleware's list too and only disappeared because the default backend is not
+ * a sandbox. A sandbox backend would have made it a 26th tool. The workbench's
+ * own copy of this list omitted it, so `isPhantomTool` could not flag the one
+ * name a sandbox backend would have brought back.
+ */
+export const PHANTOM_TOOL_NAMES = [
+ "ls",
+ "read_file",
+ "write_file",
+ "edit_file",
+ "glob",
+ "grep",
+ "execute",
+ "write_todos",
+ "task",
+] as const;
+
export const MUTATING_TOOL_NAMES: ReadonlySet<string> = new Set([
"addTrim",
"addTrims",
diff --git a/electron/ai-edition/deep-agent/service.test.ts b/electron/ai-edition/deep-agent/service.test.ts
index 43e963c22..f567da0ee 100644
--- a/electron/ai-edition/deep-agent/service.test.ts
+++ b/electron/ai-edition/deep-agent/service.test.ts
@@ -27,7 +27,12 @@ import {
ZOOM_DEPTH_LEGEND,
ZOOM_DEPTH_SCALES,
} from "../../../src/lib/ai-edition/timeline/zoom-scale";
-import { executeAgentTool, isMutatingTool } from "../agent-tools";
+import {
+ executeAgentTool,
+ isMutatingTool,
+ OPENSCREEN_TOOL_NAMES,
+ PHANTOM_TOOL_NAMES,
+} from "../agent-tools";
import {
anthropicCachingMiddleware,
buildSystemPrompt,
@@ -37,45 +42,13 @@ import {
TOOL_DESCRIPTIONS,
} from "./service";
-const OPENSCREEN_TOOLS = [
- "getCurrentDocument",
- "getTranscript",
- "getCursorTrack",
- "addTrim",
- "addTrims",
- "setTrim",
- "setClipRange",
- "moveClip",
- "replaceTimeline",
- "addZoom",
- "addZooms",
- "setZoom",
- "addSpeed",
- "setSpeed",
- "addAnnotation",
- "setAnnotation",
- "addCameraFullscreen",
- "setCameraFullscreen",
- "removeTrim",
- "removeModifier",
- "removeClip",
-];
-
-/** The tools `createDeepAgent` used to add. None of them may ever be built here
- * again: `execute` is in the middleware's list too and only disappeared at
- * runtime because the default backend is not a sandbox, so it is listed as
- * well — a sandbox backend would have made it a 26th tool. */
-const PHANTOM_TOOLS = [
- "ls",
- "read_file",
- "write_file",
- "edit_file",
- "glob",
- "grep",
- "execute",
- "write_todos",
- "task",
-];
+// Both rosters used to be re-typed here, and a third time in the workbench. This
+// file is the one that runs in CI, so its copy stayed right and the bench's went
+// stale at 19 tools — asserting a surface the product had outgrown. One list now,
+// in `agent-tools.ts`; this suite is what pins it to what `buildTools` actually
+// builds, and the bench reads the same array.
+const OPENSCREEN_TOOLS: readonly string[] = OPENSCREEN_TOOL_NAMES;
+const PHANTOM_TOOLS: readonly string[] = PHANTOM_TOOL_NAMES;
/** Valid arguments for every tool, chosen so the executor's verdict is split
* across the table: some succeed, some are refused for an unknown id, and
@@ -191,7 +164,9 @@ function toolsFor(document: AxcutDocument) {
}
describe("the tool surface handed to the model", () => {
- it("is exactly OpenScreen's 21 tools", () => {
+ // No count in the title: the number moved twice without either copy of the
+ // roster following, and a title is the one place a stale number cannot fail.
+ it("is exactly the tools OpenScreen declares, in that order", () => {
const { tools } = toolsFor(fixtureDocument());
expect(tools.map((t) => t.name)).toEqual(OPENSCREEN_TOOLS);
});
@@ -419,7 +394,7 @@ describe("the prompt when the user has turned project edits off", () => {
});
describe("the tools when the user has turned project edits off", () => {
- it("still builds all 21 — the model has to be able to NAME the edit", () => {
+ it("still builds every one — the model has to be able to NAME the edit", () => {
const { sink } = recordingSink();
const tools: BuiltTool[] = buildTools({ current: fixtureDocument() }, sink, false);
expect(tools.map((t) => t.name)).toEqual(OPENSCREEN_TOOLS);
diff --git a/workbench/l1/end-to-end.wb.ts b/workbench/l1/end-to-end.wb.ts
index 1ccfe7779..b6e8a560e 100644
--- a/workbench/l1/end-to-end.wb.ts
+++ b/workbench/l1/end-to-end.wb.ts
@@ -19,7 +19,10 @@ import { runRepetition, runScenarioReps } from "../lib/runner";
import { allScenarios, getScenario } from "../scenarios/registry";
describe("the context the model actually receives", () => {
- it("is our 19 tools and nothing else", async () => {
+ // The title used to say "19" while the agent shipped 21, and a title cannot
+ // fail. The count lives in the roster now, and the roster is pinned in CI by
+ // `deep-agent/service.test.ts` against what `buildTools` actually builds.
+ it("is our tool surface and nothing else", async () => {
const run = await runScenario({
label: "l1-surface",
prompt: "hello",
diff --git a/workbench/lib/prompts.ts b/workbench/lib/prompts.ts
index 60038cacc..b2597a0a8 100644
--- a/workbench/lib/prompts.ts
+++ b/workbench/lib/prompts.ts
@@ -2,6 +2,8 @@
// so a wording change is one edit and so the wizard prompt stays byte-identical
// to production.
+import { OPENSCREEN_TOOL_NAMES, PHANTOM_TOOL_NAMES } from "../../electron/ai-edition/agent-tools";
+
/**
* VERBATIM copy of `AI_ENHANCE_PROMPT` from
* `src/components/ai-edition/v4/V4Timeline.tsx:57-58` — the string the
@@ -11,71 +13,36 @@
export const AI_ENHANCE_PROMPT =
"Automatically enhance this recording: (1) add smart zoom-ins on the moments where the cursor dwells or interacts with the UI, each focused on the cursor's location; and (2) cut the dead time — long pauses, silences, and idle stretches where nothing happens — to keep the pacing tight and natural. Apply the edits directly to the timeline.";
-/** The 19 tools OpenScreen builds in `deep-agent/service.ts` (`buildTools`).
- * `moveClip` reordering a clip had NO tool while the system prompt promised one,
- * which is what pushed the model onto `replaceTimeline` (D-DESTRUCT).
- * `getCursorTrack` is the newest: the app records pointer telemetry and loads it
- * in the compositor, but NOTHING carried a single sample to the model, so asked
- * what cursor data the project held it had to answer from nothing (D-TELEM).
- *
- * ponytail: the name is `getCursorTrack`, not `getCursorTrack` — the tool
- * returns the TRACK (positions over time) and no longer the stillness detector's
- * digest, and this list said otherwise for a while. That is not a cosmetic
- * drift: a scenario check written as `calls("getCursorTrack").length > 0`
- * counts a call LangChain refused, so `cursor-question` and `cursor-blind` both
- * scored 1.0 on turns where nothing was ever read. Every name here is frozen
- * against the real surface by `l1/end-to-end.wb.ts`. */
-export const OPENSCREEN_TOOLS = [
- "getCurrentDocument",
- "getTranscript",
- "getCursorTrack",
- "addTrim",
- "setTrim",
- "setClipRange",
- "moveClip",
- "replaceTimeline",
- "addZoom",
- "setZoom",
- "addSpeed",
- "setSpeed",
- "addAnnotation",
- "setAnnotation",
- "addCameraFullscreen",
- "setCameraFullscreen",
- "removeTrim",
- "removeModifier",
- "removeClip",
-] as const;
-
/**
- * The 8 filesystem/todo/sub-agent tools the `deepagents` middlewares used to
- * inject on top of ours. They operated on an in-memory `StateBackend` that is
- * EMPTY, and the model was not told so — the mechanical cause of D1: asked
- * about cursor telemetry, the model ran `ls`/`glob` against that sandbox and
- * reported, in good faith, that the project contains no pointer-tracking data.
+ * The tools OpenScreen builds in `deep-agent/service.ts` (`buildTools`), and the
+ * filesystem/todo/sub-agent tools that must never appear beside them again.
+ *
+ * Both are RE-EXPORTS, not copies. The bench used to keep its own hand-written
+ * pair, and both went stale without anything noticing: the tool roster sat at 19
+ * from the day it was written while the agent grew to 21 (`addTrims`/`addZooms`),
+ * and the phantom list was missing `execute`, so `isPhantomTool` could not flag
+ * the one middleware tool a sandbox backend would have re-introduced. Nothing
+ * caught either, because `npm run wb` is not part of CI — the bench was checking
+ * the product against a surface the product had outgrown.
+ *
+ * `agent-tools.ts` is the right home for them: it already owns
+ * `MUTATING_TOOL_NAMES` and runs on zod plus pure document helpers, so importing
+ * it costs L0 nothing (four L0 files already pull `executeAgentTool` from it).
+ * Importing `deep-agent/service.ts` instead would drag LangChain down here.
*
- * The surface is gone (`deep-agent/service.ts` now calls LangChain's
- * `createAgent` with our own tools and our prompt alone), so this list changed
- * meaning rather than becoming dead: it is now the list of names that must
- * NEVER appear on the wire again. A call to one of them is no longer the model
- * using a tool it was handed — it is the model hallucinating a filesystem it
- * was never offered, which is a rarer but still exact D1 tell. `l1` freezes the
- * surface directly; the scenarios keep scoring the calls.
+ * What keeps the roster honest is `deep-agent/service.test.ts`, which asserts it
+ * equals `buildTools(...).map(t => t.name)` — and that suite runs in CI. A tool
+ * added without updating the roster now fails the build rather than a bench
+ * nobody runs.
*/
-export const PHANTOM_TOOLS = [
- "write_todos",
- "ls",
- "read_file",
- "write_file",
- "edit_file",
- "glob",
- "grep",
- "task",
-] as const;
+export const OPENSCREEN_TOOLS = OPENSCREEN_TOOL_NAMES;
+export const PHANTOM_TOOLS = PHANTOM_TOOL_NAMES;
-/** Exactly our 19, and nothing else. A change here means the agent's context
- * changed shape — which is the one thing a report cannot be compared across. */
-export const EXPECTED_TOOL_COUNT = OPENSCREEN_TOOLS.length;
+/** Our whole surface, and nothing else. A change here means the agent's context
+ * changed shape — which is the one thing a report cannot be compared across, so
+ * `fingerprintOf` records the wire's own `toolNames`/`toolsSha256` in every
+ * report rather than trusting this to have been noticed. */
+export const EXPECTED_TOOL_COUNT = OPENSCREEN_TOOL_NAMES.length;
const PHANTOM_SET: ReadonlySet<string> = new Set<string>(PHANTOM_TOOLS);