Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions shared/bot-prompt.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { describe, expect, test } from "bun:test";
import { SYSTEM_PROMPT } from "./bot-prompt";

describe("SYSTEM_PROMPT", () => {
test("keeps paragraph breaks as blank lines instead of collapsing them into spaces", () => {
expect(SYSTEM_PROMPT).toContain("\n\n");
expect(SYSTEM_PROMPT).not.toContain(" ");
});

test("keeps each paragraph as one unbroken line of prose", () => {
for (const paragraph of SYSTEM_PROMPT.split("\n\n")) {
expect(paragraph).not.toContain("\n");
expect(paragraph.length).toBeGreaterThan(0);
}
});

test("still contains the full instruction text, unchanged in wording", () => {
expect(SYSTEM_PROMPT).toContain(
"You are a Bot with your own computer, a real web browser the person can watch you use.",
);
expect(SYSTEM_PROMPT).toContain(
"Say what you found or did in plain language, briefly.",
);
});
});
22 changes: 20 additions & 2 deletions shared/bot-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* The prompt requires snapshot-first computer use. Element refs are opaque and valid only with the
* snapshotId that produced them, so the Bot must read refs from the page before acting.
*/
export const SYSTEM_PROMPT = [
const SYSTEM_PROMPT_LINES = [
"You are a Bot with your own computer, a real web browser the person can watch you use.",
"When you are asked to look at, open, visit, check or read a web page, call computer_navigate.",
"Never claim you cannot browse: opening a page is something you can actually do.",
Expand Down Expand Up @@ -53,4 +53,22 @@ export const SYSTEM_PROMPT = [
"something to retry: say plainly what was blocked and why, and stop. Do not try another route to",
"the same thing.",
"Say what you found or did in plain language, briefly.",
].join(" ");
];

/**
* `SYSTEM_PROMPT_LINES` uses `""` as a paragraph break. Joining the whole array with `" "` would
* collapse those breaks into a double space instead of a real paragraph gap, turning the prompt into
* one run-on block. Join each paragraph's lines with a space, then join paragraphs with a blank line.
*/
export const SYSTEM_PROMPT = SYSTEM_PROMPT_LINES.reduce<string[]>(
(paragraphs, line) => {
if (line === "") {
paragraphs.push("");
return paragraphs;
}
const last = paragraphs.length - 1;
paragraphs[last] = paragraphs[last] ? `${paragraphs[last]} ${line}` : line;
return paragraphs;
},
[""],
).join("\n\n");