Skip to content

Commit c9712c8

Browse files
committed
refactor(canvas): drop vestigial anti-rewrite prompting from canvas tools
The "do not regenerate wholesale" phrasing in the checkout tool description, its runtime message, and the generation prompt warned against a workflow a fresh agent never sees, and could bias against legitimately large rewrites. The one forward-looking economy nudge (prefer targeted edits over rewriting the whole file for a small change) stays in the authoring contract in canvasTemplates.ts, stated once. Generated-By: PostHog Code Task-Id: 2b3d176e-3023-41d2-92e8-81eda7c12a8c
1 parent e9b12cd commit c9712c8

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

packages/agent/src/adapters/local-tools/tools/canvas.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ export const canvasCheckoutTool = defineLocalTool({
121121
description:
122122
"Check out a PostHog canvas (a freeform React desktop-fs dashboard) for editing: fetches the live " +
123123
"source, writes it to a local scratch file, and records the version your edits are based on. " +
124-
"Returns the file path. Edit that file with your normal file-editing tools (targeted edits — do not " +
125-
"regenerate it wholesale), then call canvas_publish to save. Always start canvas work with this tool.",
124+
"Returns the file path. Edit that file with your normal file-editing tools, then call " +
125+
"canvas_publish to save. Always start canvas work with this tool.",
126126
schema: {
127127
id: z.string().describe("The canvas (desktop-fs dashboard row) id."),
128128
},
@@ -143,7 +143,7 @@ export const canvasCheckoutTool = defineLocalTool({
143143
const text = code
144144
? `Checked out canvas "${entry.path}" to ${file} (${lines} lines, base version ${
145145
entry.meta?.currentVersionId ?? "none"
146-
}).\nApply your changes by EDITING that file (targeted edits), then call canvas_publish with id "${args.id}".`
146+
}).\nApply your changes by editing that file, then call canvas_publish with id "${args.id}".`
147147
: `Canvas "${entry.path}" is empty. Author the complete single-file React app at ${file}, then call canvas_publish with id "${args.id}".`;
148148
return { content: [{ type: "text", text }] };
149149
} catch (err) {

packages/ui/src/features/canvas/freeformPrompt.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe("buildFreeformGenerationPrompt", () => {
5050
// the live code tool-side and the agent edits the scratch file in place.
5151
expect(extracted?.body).not.toContain("export const App = () => null;");
5252
expect(extracted?.body).toContain("canvas_checkout");
53-
expect(extracted?.body).toContain("TARGETED edits");
53+
expect(extracted?.body).toContain("editing that file");
5454
// The stale-publish recovery loop is spelled out.
5555
expect(extracted?.body).toContain("version-conflict");
5656
});

packages/ui/src/features/canvas/freeformPrompt.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ source to a local scratch file and returns the path.`;
5858

5959
const editStep = isEdit
6060
? `
61-
Then apply the user's request by EDITING that file with your file-editing
62-
tools. Make TARGETED edits — do not rewrite the whole file for a small change,
63-
and do not paste the source into chat.
61+
Then apply the user's request by editing that file with your file-editing
62+
tools. Do not paste the source into chat.
6463
`
6564
: "";
6665

0 commit comments

Comments
 (0)