Browser tools: initialize lazily and add timeouts.
Also rename browser_screenshot to browser_take_screenshot for clarity\n- Update both Go and UI code to maintain consistency
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s8a5cabff914f88dfk
diff --git a/loop/testdata/agent_loop.httprr b/loop/testdata/agent_loop.httprr
index 512e5d1..fe631a1 100644
--- a/loop/testdata/agent_loop.httprr
+++ b/loop/testdata/agent_loop.httprr
@@ -1,9 +1,9 @@
httprr trace v1
-14628 2230
+15608 2329
POST https://api.anthropic.com/v1/messages HTTP/1.1
Host: api.anthropic.com
User-Agent: Go-http-client/1.1
-Content-Length: 14430
+Content-Length: 15410
Anthropic-Version: 2023-06-01
Content-Type: application/json
@@ -245,6 +245,10 @@
"url": {
"type": "string",
"description": "The URL to navigate to"
+ },
+ "timeout": {
+ "type": "string",
+ "description": "Timeout as a Go duration string (default: 5s)"
}
},
"required": [
@@ -265,6 +269,10 @@
"wait_visible": {
"type": "boolean",
"description": "Wait for the element to be visible before clicking"
+ },
+ "timeout": {
+ "type": "string",
+ "description": "Timeout as a Go duration string (default: 5s)"
}
},
"required": [
@@ -289,6 +297,10 @@
"clear": {
"type": "boolean",
"description": "Clear the input field before typing"
+ },
+ "timeout": {
+ "type": "string",
+ "description": "Timeout as a Go duration string (default: 5s)"
}
},
"required": [
@@ -307,9 +319,9 @@
"type": "string",
"description": "CSS selector for the element to wait for"
},
- "timeout_ms": {
- "type": "integer",
- "description": "Maximum time to wait in milliseconds (default: 30000)"
+ "timeout": {
+ "type": "string",
+ "description": "Timeout as a Go duration string (default: 5s)"
}
},
"required": [
@@ -319,13 +331,17 @@
},
{
"name": "browser_get_text",
- "description": "Get the innerText of an element",
+ "description": "Get the innerText of an element. Can be used to read the web page.",
"input_schema": {
"type": "object",
"properties": {
"selector": {
"type": "string",
"description": "CSS selector for the element to get text from"
+ },
+ "timeout": {
+ "type": "string",
+ "description": "Timeout as a Go duration string (default: 5s)"
}
},
"required": [
@@ -342,6 +358,10 @@
"expression": {
"type": "string",
"description": "JavaScript expression to evaluate"
+ },
+ "timeout": {
+ "type": "string",
+ "description": "Timeout as a Go duration string (default: 5s)"
}
},
"required": [
@@ -358,6 +378,10 @@
"selector": {
"type": "string",
"description": "CSS selector for the element to scroll into view"
+ },
+ "timeout": {
+ "type": "string",
+ "description": "Timeout as a Go duration string (default: 5s)"
}
},
"required": [
@@ -366,7 +390,7 @@
}
},
{
- "name": "browser_screenshot",
+ "name": "browser_take_screenshot",
"description": "Take a screenshot of the page or a specific element",
"input_schema": {
"type": "object",
@@ -382,6 +406,10 @@
"base64",
"png"
]
+ },
+ "timeout": {
+ "type": "string",
+ "description": "Timeout as a Go duration string (default: 5s)"
}
}
}
@@ -395,6 +423,10 @@
"path": {
"type": "string",
"description": "Path to the image file to read"
+ },
+ "timeout": {
+ "type": "string",
+ "description": "Timeout as a Go duration string (default: 5s)"
}
},
"required": [
@@ -463,25 +495,25 @@
}HTTP/2.0 200 OK
Anthropic-Organization-Id: 3c473a21-7208-450a-a9f8-80aebda45c1b
Anthropic-Ratelimit-Input-Tokens-Limit: 200000
-Anthropic-Ratelimit-Input-Tokens-Remaining: 200000
-Anthropic-Ratelimit-Input-Tokens-Reset: 2025-05-10T13:34:48Z
+Anthropic-Ratelimit-Input-Tokens-Remaining: 199000
+Anthropic-Ratelimit-Input-Tokens-Reset: 2025-05-11T01:21:43Z
Anthropic-Ratelimit-Output-Tokens-Limit: 80000
Anthropic-Ratelimit-Output-Tokens-Remaining: 80000
-Anthropic-Ratelimit-Output-Tokens-Reset: 2025-05-10T13:34:52Z
+Anthropic-Ratelimit-Output-Tokens-Reset: 2025-05-11T01:21:47Z
Anthropic-Ratelimit-Requests-Limit: 4000
Anthropic-Ratelimit-Requests-Remaining: 3999
-Anthropic-Ratelimit-Requests-Reset: 2025-05-10T13:34:47Z
+Anthropic-Ratelimit-Requests-Reset: 2025-05-11T01:21:42Z
Anthropic-Ratelimit-Tokens-Limit: 280000
-Anthropic-Ratelimit-Tokens-Remaining: 280000
-Anthropic-Ratelimit-Tokens-Reset: 2025-05-10T13:34:48Z
+Anthropic-Ratelimit-Tokens-Remaining: 279000
+Anthropic-Ratelimit-Tokens-Reset: 2025-05-11T01:21:43Z
Cf-Cache-Status: DYNAMIC
-Cf-Ray: 93d9d0e80caa67fe-SJC
+Cf-Ray: 93dddc70ba53942c-SJC
Content-Type: application/json
-Date: Sat, 10 May 2025 13:34:52 GMT
-Request-Id: req_011CNywHj3Qrj3hEz9qFRVgK
+Date: Sun, 11 May 2025 01:21:47 GMT
+Request-Id: req_011CNzsCMP4tG7GTL8PrNTDw
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Via: 1.1 google
X-Robots-Tag: none
-{"id":"msg_014KGRNEmFdTUGqDQN7sRmzc","type":"message","role":"assistant","model":"claude-3-7-sonnet-20250219","content":[{"type":"text","text":"Here are the tools available to me:\n\n1. bash - Executes shell commands\n2. keyword_search - Searches files with given keywords\n3. think - For recording thoughts, notes, and plans\n4. title - Sets conversation title\n5. precommit - Creates git branches and provides commit message guidance\n6. done - Marks task completion with a checklist\n7. codereview - Runs automated code review\n8. multiplechoice - Presents multiple choice options to the user\n9. Browser tools:\n - browser_navigate - Opens a URL\n - browser_click - Clicks elements\n - browser_type - Types text into elements\n - browser_wait_for - Waits for elements\n - browser_get_text - Gets text from elements\n - browser_eval - Runs JavaScript in browser\n - browser_scroll_into_view - Scrolls to elements\n - browser_screenshot - Takes screenshots\n - browser_read_image - Reads image files\n10. patch - Makes precise text modifications to files"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":3376,"cache_read_input_tokens":0,"output_tokens":236}}
\ No newline at end of file
+{"id":"msg_0152wEWVypxw8wDR31nYSXQd","type":"message","role":"assistant","model":"claude-3-7-sonnet-20250219","content":[{"type":"text","text":"Here are the tools available to me:\n\n1. bash - Execute shell commands\n2. keyword_search - Search for files based on keywords\n3. think - Record thoughts and plans\n4. title - Set conversation title\n5. precommit - Create a git branch for work\n6. done - Mark a task as complete with checklist\n7. codereview - Run automated code review\n8. multiplechoice - Present multiple choice options to user\n9. Browser tools:\n - browser_navigate - Navigate to URLs\n - browser_click - Click elements\n - browser_type - Type into elements\n - browser_wait_for - Wait for elements\n - browser_get_text - Get text from elements\n - browser_eval - Evaluate JavaScript\n - browser_scroll_into_view - Scroll elements into view\n - browser_take_screenshot - Take screenshots\n - browser_read_image - Read image files\n10. patch - Make precise text edits to files\n\nThese tools allow me to execute commands, search codebases, plan, manage git branches, evaluate code, interact with web browsers, and make file modifications."}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":3609,"cache_read_input_tokens":0,"output_tokens":254}}
\ No newline at end of file