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
5 changes: 5 additions & 0 deletions .changeset/quick-clouds-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

update cua agents key & system prompt handling
8 changes: 5 additions & 3 deletions lib/agent/GoogleCUAClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,16 @@ export class GoogleCUAClient extends AgentClient {
// Note: The Python implementation doesn't include the initial screenshot
// Following the same pattern here

const systemPromptContent = this.userProvidedInstructions
? this.userProvidedInstructions
: buildGoogleCUASystemPrompt().content;

this.history = [
{
role: "user",
parts: [
{
text:
"System prompt: " +
(buildGoogleCUASystemPrompt().content as string),
text: "System prompt: " + systemPromptContent,
},
],
},
Expand Down
5 changes: 4 additions & 1 deletion lib/handlers/cuaAgentHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ export class CuaAgentHandler {
case "keypress": {
const { keys } = action;
if (Array.isArray(keys)) {
await this.page.keyboard.press(keys.join("+"));
const mappedKeys = keys.map((key) =>
mapKeyToPlaywright(String(key)),
);
await this.page.keyboard.press(mappedKeys.join("+"));
}
return { success: true };
}
Expand Down