Skip to content

Commit 245482b

Browse files
committed
examples/think: Guide seeded fixture agents
Tell the comparison agents that the fixture files already exist before a run starts. The prompt now treats tool results as the source of truth and asks agents to report visibility mismatches instead of creating replacement project scaffolding.
1 parent 5092308 commit 245482b

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

examples/think-compare-runtimes/worker/think/prompts.test.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ describe("runtime Think prompts", () => {
2626
expect(prompt).toContain(
2727
"After validation passes, stop editing and summarize the completed work.",
2828
);
29+
expect(prompt).toContain("The fixture files are already seeded before you start.");
30+
expect(prompt).toContain("Tool results are facts; reasoning is provisional.");
31+
expect(prompt).toContain(
32+
"Do not claim a directory is empty or missing unless a tool result shows that.",
33+
);
34+
expect(prompt).toContain(
35+
"If expected fixture files appear missing, report a runtime visibility issue instead of bootstrapping replacement project files.",
36+
);
2937
}
3038
});
3139

@@ -58,8 +66,16 @@ describe("runtime Think prompts", () => {
5866
expect(prompt).toContain(
5967
"Locate related Workers docs and examples before drafting the new page.",
6068
);
61-
expect(prompt).not.toContain("Known project files:");
62-
expect(prompt).not.toContain("- /workspace/repo/package.json");
69+
expect(prompt).toContain("Seeded project files:");
70+
for (const file of comparisonFixture.files) {
71+
expect(prompt).toContain(`- /workspace/repo/${file.path}`);
72+
}
73+
expect(prompt).toContain(
74+
"These files are already present at run start; do not recreate the baseline project.",
75+
);
76+
expect(prompt).toContain(
77+
"If a listing appears inconsistent with this manifest, verify by reading known paths and report the inconsistency instead of creating substitute files.",
78+
);
6379
expect(prompt).toContain("Acceptance criteria:");
6480
expect(prompt).toContain("Create /workspace/repo/docs/workers/smart-request-policies.md.");
6581
expect(prompt).toContain("Include the exact header name `x-bypass-token`.");
@@ -87,11 +103,17 @@ describe("runtime Think prompts", () => {
87103
expect(workspace.exec).toContain(
88104
"After validation passes, summarize the work instead of making extra edits",
89105
);
106+
expect(workspace.exec).toContain(
107+
"If discovery commands disagree with successful reads of seeded files, verify known paths and report a visibility issue",
108+
);
90109
expect(sandbox.read).toContain("Sandbox filesystem");
91110
expect(sandbox.read).toContain("absolute path under /workspace/repo");
92111
expect(sandbox.exec).toContain(
93112
"Use this freely for search, listing, project inspection, package scripts, tests",
94113
);
95114
expect(sandbox.exec).toContain("If validation fails, repair the files and rerun the command");
115+
expect(sandbox.exec).toContain(
116+
"Do not bootstrap replacement project files if seeded fixture paths are already readable",
117+
);
96118
});
97119
});

examples/think-compare-runtimes/worker/think/prompts.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ export function createTaskPrompt(fixture: ComparisonFixture): string {
3030
"",
3131
"Locate related Workers docs and examples before drafting the new page.",
3232
"",
33+
"Seeded project files:",
34+
...fixture.files.map((file) => `- ${root}/${file.path}`),
35+
"",
36+
"These files are already present at run start; do not recreate the baseline project.",
37+
"If a listing appears inconsistent with this manifest, verify by reading known paths and report the inconsistency instead of creating substitute files.",
38+
"",
3339
"Acceptance criteria:",
3440
`- Create ${root}/docs/workers/smart-request-policies.md.`,
3541
"- Start the new page with YAML frontmatter containing `title`, `description`, and `lastUpdated`.",
@@ -55,7 +61,7 @@ export function createRuntimeToolDescriptions(runtime: RuntimeId): RuntimeToolDe
5561
write:
5662
"Create or overwrite a text file with Workspace file tools. Use an absolute path under /workspace/repo. This replaces the whole file, so use it for new files or full-file rewrites.",
5763
edit: "Apply exact text replacements with Workspace file tools. Use an absolute path under /workspace/repo. Each oldText must match exactly one current region in the file; read the file first if you need exact text.",
58-
exec: "Run a shell command through the Workspace environment. grep, find, ls, cat, pwd, head, tail, sed, and wc route to the worker shell for fast text inspection. npm, node, npx, pnpm, yarn, vitest, tsc, and executable project scripts route to the workspace container for package/runtime work. cwd defaults to /workspace/repo and must stay under /workspace/repo. If validation fails, repair the files and rerun the command. After validation passes, summarize the work instead of making extra edits.",
64+
exec: "Run a shell command through the Workspace environment. grep, find, ls, cat, pwd, head, tail, sed, and wc route to the worker shell for fast text inspection. npm, node, npx, pnpm, yarn, vitest, tsc, and executable project scripts route to the workspace container for package/runtime work. cwd defaults to /workspace/repo and must stay under /workspace/repo. If discovery commands disagree with successful reads of seeded files, verify known paths and report a visibility issue instead. If validation fails, repair the files and rerun the command. After validation passes, summarize the work instead of making extra edits.",
5965
};
6066
}
6167

@@ -64,7 +70,7 @@ export function createRuntimeToolDescriptions(runtime: RuntimeId): RuntimeToolDe
6470
write:
6571
"Create or overwrite a text file in the Sandbox filesystem. Use an absolute path under /workspace/repo. This replaces the whole file, so use it for new files or full-file rewrites.",
6672
edit: "Apply exact text replacements to a file in the Sandbox filesystem. Use an absolute path under /workspace/repo. Each oldText must match exactly one current region in the file; read the file first if you need exact text.",
67-
exec: "Run a shell command inside the Sandbox container. Use this freely for search, listing, project inspection, package scripts, tests, and other shell-native workflows. cwd defaults to /workspace/repo and must stay under /workspace/repo. If validation fails, repair the files and rerun the command.",
73+
exec: "Run a shell command inside the Sandbox container. Use this freely for search, listing, project inspection, package scripts, tests, and other shell-native workflows. cwd defaults to /workspace/repo and must stay under /workspace/repo. Do not bootstrap replacement project files if seeded fixture paths are already readable; verify known paths and report a visibility issue instead. If validation fails, repair the files and rerun the command.",
6874
};
6975
}
7076

@@ -83,6 +89,10 @@ function sharedCodingPrompt(): string {
8389
"- Keep changes minimal and focused on the task.",
8490
"- Treat validation failures as actionable repair checklists, then rerun validation when possible.",
8591
"- After validation passes, stop editing and summarize the completed work.",
92+
"- The fixture files are already seeded before you start.",
93+
"- Tool results are facts; reasoning is provisional.",
94+
"- Do not claim a directory is empty or missing unless a tool result shows that.",
95+
"- If expected fixture files appear missing, report a runtime visibility issue instead of bootstrapping replacement project files.",
8696
].join("\n");
8797
}
8898

0 commit comments

Comments
 (0)