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

Add goto tool to anthropicCuaClient
31 changes: 29 additions & 2 deletions lib/agent/AnthropicCUAClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,20 @@ export class AnthropicCUAClient extends AgentClient {
display_height_px: this.currentViewport.height,
display_number: 1,
},
{
name: "goto",
description: "Navigate to a specific URL",
input_schema: {
type: "object",
properties: {
url: {
type: "string",
description: "The URL to navigate to",
},
},
required: ["url"],
},
},
],
betas: ["computer-use-2025-01-24"],
};
Expand Down Expand Up @@ -585,9 +599,16 @@ export class AnthropicCUAClient extends AgentClient {
level: 2,
});
} else {
// Handle custom tools
// Handle custom tools and built-in tools like goto
let toolResult = "Tool executed successfully";
if (this.tools && item.name in this.tools) {
if (item.name === "goto") {
try {
const url = item.input.url;
toolResult = `Successfully navigated to ${url}`;
} catch (error) {
toolResult = `Error with goto: ${error instanceof Error ? error.message : String(error)}`;
}
Comment on lines +604 to +610
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The goto tool claims success but doesn't actually perform navigation. It only extracts the URL and returns a success message without calling any navigation logic.

Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/agent/AnthropicCUAClient.ts
Line: 604:610

Comment:
**logic:** The goto tool claims success but doesn't actually perform navigation. It only extracts the URL and returns a success message without calling any navigation logic.

How can I resolve this? If you propose a fix, please make it concise.

} else if (this.tools && item.name in this.tools) {
try {
const tool = this.tools[item.name];

Expand Down Expand Up @@ -890,6 +911,12 @@ export class AnthropicCUAClient extends AgentClient {
...input,
};
}
} else if (name === "goto") {
return {
type: "function",
name: "goto",
arguments: { url: input.url },
};
} else if (name === "str_replace_editor" || name === "bash") {
// For editor or bash tools
return {
Expand Down