Skip to content
Merged
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
2 changes: 1 addition & 1 deletion agent-claude-sdk/tests/fixtures/server-instructions.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions agent-claude-sdk/tests/test_openbot_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ async def scenario():
" summarize it or answer from it" in flat
)
assert "say what you did not read at the start of your reply" in flat
# Asked by the person, it uses its computer, also when an app could not be connected (found in
# dogfooding with Gusto: "I can't use the computer as a workaround for Gusto's app connection").
assert (
"When you have a computer and the person asks you to do something on it or in its browser, do it"
" that way, including when an app could not be connected or its connection did not work" in flat
)
assert "an app that is switched off or cannot be connected here is not a rule against its website" in flat
# Told OpenBot asks before what it gives the Bot, so the Bot does not ask a second time.
assert "When you use the apps and tools OpenBot gives you, OpenBot asks" in system_prompt
# The server's instructions are the whole prompt, first: Claude Code's own is not added.
Expand Down
17 changes: 10 additions & 7 deletions app/src/lib/copilot/computer-tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -742,15 +742,18 @@ export function ComputerTools() {
useFrontendTool({
name: "computer_request_help",
description:
"Ask the person to take control of your computer and do something you cannot: sign in, enter a " +
"password or a one-time code, or clear a CAPTCHA. Say specifically what you need done. They " +
"will drive the browser themselves and hand it back, and you carry on in the same session. " +
"Ask the person to take control of your computer and do something you cannot: enter a one-time " +
"code, use a passkey, or clear a CAPTCHA. For a sign-in page, call computer_request_sign_in " +
"instead, if you hold it: its private form offers a saved login, typing one in once, or taking " +
"over. Say specifically what you need done. They will drive the browser themselves and hand it " +
"back, and you carry on in the same session. " +
"Use this INSTEAD of giving up, and instead of ever asking them to type a password to you. " +
"This call is the only thing that reaches them: until you make it they are not looking at the " +
"page and have no way to help, so saying you need them to sign in, or asking whether they would " +
"like to proceed, hands over nothing and leaves the page where it is. " +
"Also call this whenever the person asks to take over the browser, or to type a password or " +
"anything else into it themselves: they are asking for the browser, not for computer_request_secret.",
"page and have no way to help, so saying you need them to do something, or asking whether they " +
"would like to proceed, hands over nothing and leaves the page where it is. " +
"Also call this whenever the person asks to take over the browser on a page that is not a " +
"sign-in, or to type something into it themselves: they are asking for the browser, not for " +
"computer_request_secret.",
parameters: z.object({
reason: z
.string()
Expand Down
85 changes: 81 additions & 4 deletions shared/bot-prompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,46 @@ describe("computerGuidance", () => {
});
});

describe("a person who asks to type it themselves gets the browser", () => {
describe("a sign-in goes to the private form", () => {
/*
* FOUND ON OPENBOT CLOUD. Told that every sign-in was a take-over (`computer_request_help`), a Bot
* asked to open Fireflies in its browser handed the person the wheel and had them type their
* password into the page. The private form (`computer_request_sign_in`) offers a saved login,
* typing one in once, or taking over, and the prompt never named it.
*/
test.each([
["with a search tool", WITH_SEARCH],
["without one", WITHOUT_SEARCH],
])(
"a sign-in page calls computer_request_sign_in, and a take-over is for the rest, %s",
(_, guidance) => {
const text = flat(guidance);
const signIn = text.indexOf(
"on a sign-in page, call computer_request_sign_in with the site's address",
);
expect(signIn).toBeGreaterThan(-1);
expect(text).toContain(
"they can pick a login they saved, type one in once, or take over your browser",
);
// A person who says they will sign in themselves still gets the form, which lets them.
expect(text).toContain(
"call it for every sign-in, also when the person says they will sign in or type their password themselves",
);
// A take-over is what is left, after the sign-in: never the way to sign in.
const takeOver = text.indexOf(
"for anything else only a person can do on a page, such as a captcha, a one-time code or a passkey, call computer_request_help",
);
expect(takeOver).toBeGreaterThan(signIn);
expect(text).not.toContain(
"a sign-in, a password, a code sent to their phone, a captcha. when you hit one, call computer_request_help",
);
// The words that used to stand in for asking now name the form.
expect(text).toContain(
"'once you have signed in, tell me', call computer_request_sign_in",
);
},
);

/*
* The computer-sign-in journey: "hand me the browser so I can type my password myself". In 2 of
* 2 fresh live recordings the Bot called computer_request_secret (the masked box) instead, because
Expand All @@ -191,14 +230,14 @@ describe("a person who asks to type it themselves gets the browser", () => {
(_, guidance) => {
const text = flat(guidance);
const handOver = text.indexOf(
"when the person says they will type it themselves, or asks you to hand them the browser or let them take over, call computer_request_help",
"when the person asks you to hand them the browser or let them take over a page that is not a sign-in, or says they will type something into it themselves, call computer_request_help",
);
const maskedBox = text.indexOf(
"otherwise, when you need a single value, a password, a code, a card number, do not hand over the whole browser. call computer_request_secret",
"otherwise, when you need a single value that is not part of a sign-in, such as a card number, do not hand over the whole browser. call computer_request_secret",
);
expect(handOver).toBeGreaterThan(-1);
expect(maskedBox).toBeGreaterThan(handOver);
expect(text).toContain("even for a single password");
expect(text).toContain("even for a single value");
},
);
});
Expand Down Expand Up @@ -340,6 +379,44 @@ describe("how a Bot asks, and how an unattended run ends", () => {
}
});

/*
* Found in dogfooding: Gusto could not be connected, the person asked the Bot to try with its
* computer, and it said it couldn't use the computer as a workaround for the app's connection.
*/
test("asked by the person, a Bot uses its computer, also when an app could not be connected, within the safety rules", () => {
for (const brought of [false, true]) {
const [howTo] = workingGuidance({ brought, untrusted: "" });
const said = flat(howTo ?? "");
expect(said).toContain(
"when you have a computer and the person asks you to do something on it or in its browser, do it that way, including when an app could not be connected or its connection did not work",
);
expect(said).toContain(
"a rule against browsing to an app's website is about what you choose yourself, never a reason to refuse them",
);
expect(said).toContain(
"an app that is switched off or cannot be connected here is not a rule against its website",
);
// The safety rules stand: the person signs in, OpenBot still asks, a blocked site stays blocked.
expect(said).toContain(
"a sign-in on the way is theirs to do, the way your computer's instructions say, never a password they give you in this conversation",
);
expect(said).toContain(
"openbot still asks before what it always asks about",
);
expect(said).toContain(
"anything this deployment blocks in your browser stays blocked",
);
// Offered once when a connection fails, never pushed.
expect(said).toContain(
"you may offer once to try it in your browser instead, without pressing it",
);
}
// The policy refusal a Bot meets in its browser is still not to be got around.
expect(flat(WITH_SEARCH)).toContain(
"trying that action again or another way would only get around the rule",
);
});

test("only what is private to the person or their team gets the card: anything public still goes to the web", () => {
// A rule for "what is kept in an app" also covers a public repository's release, a public
// document and a dead public link, which would stall on a card the person never needed.
Expand Down
82 changes: 68 additions & 14 deletions shared/bot-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,37 @@ const ACTING_LINES = [
"'There is no file at X' means that file does not exist. It is not a policy restriction, so do not",
"describe it as one. List the workspace and work from what is really in it.",
"",
"Some pages need a person: a sign-in, a password, a code sent to their phone, a CAPTCHA.",
"When you hit one, call computer_request_help and say exactly what you need done. The person takes",
"control of your browser, does that part, and hands it back, and you continue in the same session.",
"Calling it is how you ask. Words in your answer are not: nobody is offered the wheel by a sentence,",
"and the page stays exactly where it is. So instead of writing 'please sign in and let me know' or",
"'once you have signed in, tell me', call it. If you are about to say the task needs somebody signed",
"in, that sentence is the tool call: make it.",
/*
* A SIGN-IN GOES TO THE PRIVATE FORM. Found on OpenBot Cloud: told that every sign-in was a
* take-over, a Bot asked to open Fireflies in its browser handed the person the wheel and had them
* type their password into the page, when the private form (`computer_request_sign_in`) would have
* offered their saved login. A take-over stays for what the form is not for.
*/
"Some pages need a person: a sign-in, a code sent to their phone, a passkey, a CAPTCHA.",
"On a sign-in page, call computer_request_sign_in with the site's address. The person gets a",
"private sign-in form: they can pick a login they saved, type one in once, or take over your browser",
"and sign in by hand. Their login goes straight into the page, you never see it, and you carry on in",
"the same session once they are signed in. Call it for every sign-in, also when the person says they",
"will sign in or type their password themselves: the form is where they do that.",
"If you do not hold computer_request_sign_in, call computer_request_help for a sign-in instead.",
"For anything else only a person can do on a page, such as a CAPTCHA, a one-time code or a passkey,",
"call computer_request_help and say exactly what you need done. The person takes control of your",
"browser, does that part, and hands it back, and you continue in the same session.",
"Calling one of these is how you ask. Words in your answer are not: nobody is offered the form or",
"the wheel by a sentence, and the page stays exactly where it is. So instead of writing 'please sign",
"in and let me know' or 'once you have signed in, tell me', call computer_request_sign_in. If you are",
"about to say the task needs somebody signed in, that sentence is the tool call: make it.",
"The person is not looking at this page and cannot type into it until you hand it over. Do not ask",
"them to enter a username, a password or a code, neither into this conversation nor 'on the sign-in",
"page': you do not need it, should not hold it, and they cannot reach the page anyway.",
"When the person says they will type it themselves, or asks you to hand them the browser or let",
"them take over, call computer_request_help: they are asking for the wheel, and the masked box is",
"not what they asked for, even for a single password.",
"Otherwise, when you need a single value, a password, a code, a card number, do not hand over the",
"whole browser. Call computer_request_secret with that field's ref and a short label, without clicking",
"the field first: clicking a password field hands that step to the person instead. They type the",
"value into a masked box that goes straight into the field, and you never see it.",
"When the person asks you to hand them the browser or let them take over a page that is not a",
"sign-in, or says they will type something into it themselves, call computer_request_help: they are",
"asking for the wheel, and the masked box is not what they asked for, even for a single value.",
"Otherwise, when you need a single value that is not part of a sign-in, such as a card number, do",
"not hand over the whole browser. Call computer_request_secret with that field's ref and a short",
"label, without clicking the field first: clicking a password field hands that step to the person",
"instead. They type the value into a masked box that goes straight into the field, and you never",
"see it.",
"Use a full takeover for anything more involved than one field.",
"While a person has control your actions are refused with 'A person has control'. That is not an",
"error: wait, say you are waiting, and continue when it is handed back.",
Expand Down Expand Up @@ -576,6 +590,44 @@ export const BROUGHT_BOT_ASKING_GUIDANCE = asParagraphs(
BROUGHT_BOT_ASKING_GUIDANCE_LINES,
);

/**
* The computer when the person asks for it, an app's connection failed or not.
*
* FOUND IN DOGFOODING. Gusto could not be connected on the deployment, so the person asked the Bot to
* try with its computer instead, and it answered "I can't use the computer as a workaround for
* Gusto's app connection." Nothing in the Bot's own caution said that: we did. Every answer about an
* app ends "Do not browse to its website or ask them to sign in there", and the apps guidance says
* "Do not browse to its website instead" for any app the Bot does not hold. Those lines are right
* for what a Bot picks for itself (a connector reaches the app as the person, and the browser is
* signed in as nobody), and they had no word for the person asking. Read last, beside "switched off
* on this deployment", they read as a rule against the website.
*
* So every Bot is told that the person asking decides it, including when an app could not be
* connected, and that an app switched off here is not a rule against its website. The rules that
* keep it safe are said with it, because they still hold: a sign-in stays the person's, done the
* way the computer guidance says and never as a password given in the conversation, OpenBot's
* approvals still ask, and a site this deployment blocks in the browser stays blocked (the
* policy-refusal paragraph in `ACTING_LINES`). The sign-in is named by where its rule lives rather
* than by a tool, so this paragraph stays true whichever tool the computer guidance sends a sign-in
* to. It may be offered once when a connection fails, never pressed: the connection is still the
* better path when it works. Worded for a Bot with a computer, since every Bot gets these rules,
* with or without one.
*
* The "do not browse" lines themselves are the server's, in what it says about an app, and carry
* the same exception there, so the rule and its exception are read together wherever it is said.
*/
const COMPUTER_WHEN_ASKED_LINES = [
"When you have a computer and the person asks you to do something on it or in its browser, do it",
"that way, including when an app could not be connected or its connection did not work. A rule",
"against browsing to an app's website is about what you choose yourself, never a reason to refuse",
"them, and an app that is switched off or cannot be connected here is not a rule against its",
"website. Everything else still holds: a sign-in on the way is theirs to do, the way your computer's",
"instructions say, never a password they give you in this conversation; OpenBot still asks before",
"what it always asks about; and anything this deployment blocks in your browser stays blocked.",
"When an app could not be connected or keeps failing and you have a computer, you may offer once",
"to try it in your browser instead, without pressing it.",
];

/**
* How to work: the one block that says how a Bot gets a job done, for every Bot alike.
*
Expand Down Expand Up @@ -694,6 +746,8 @@ const HOW_TO_WORK_LINES = [
"nobody is watching this run, or you do not hold that tool, call no card: say which app would need",
"connecting.",
"",
...COMPUTER_WHEN_ASKED_LINES,
"",
"Do what was asked, at the scope it was asked. Do the reads and preparation a task needs without",
"asking, and when you decide on a step of it, take it in the same reply instead of saying you will.",
"Do not start work nobody asked for: a question gets its answer, not the job it is about. When you",
Expand Down
Loading