Skip to content

Commit a63a9f6

Browse files
committed
update cua agents key & system prompt handling
1 parent 7da5b55 commit a63a9f6

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

.changeset/quick-clouds-kick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@browserbasehq/stagehand": patch
3+
---
4+
5+
update cua agents key & system prompt handling

lib/agent/GoogleCUAClient.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,16 @@ export class GoogleCUAClient extends AgentClient {
203203
// Note: The Python implementation doesn't include the initial screenshot
204204
// Following the same pattern here
205205

206+
const systemPromptContent = this.userProvidedInstructions
207+
? this.userProvidedInstructions
208+
: buildGoogleCUASystemPrompt().content;
209+
206210
this.history = [
207211
{
208212
role: "user",
209213
parts: [
210214
{
211-
text:
212-
"System prompt: " +
213-
(buildGoogleCUASystemPrompt().content as string),
215+
text: "System prompt: " + systemPromptContent,
214216
},
215217
],
216218
},

lib/handlers/cuaAgentHandler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@ export class CuaAgentHandler {
271271
case "keypress": {
272272
const { keys } = action;
273273
if (Array.isArray(keys)) {
274-
await this.page.keyboard.press(keys.join("+"));
274+
const mappedKeys = keys.map((key) =>
275+
mapKeyToPlaywright(String(key)),
276+
);
277+
await this.page.keyboard.press(mappedKeys.join("+"));
275278
}
276279
return { success: true };
277280
}

0 commit comments

Comments
 (0)