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/claudetool/browse/register.go b/claudetool/browse/register.go
index 183bf14..0e60d73 100644
--- a/claudetool/browse/register.go
+++ b/claudetool/browse/register.go
@@ -2,22 +2,16 @@
import (
"context"
- "log"
"sketch.dev/llm"
)
-// RegisterBrowserTools initializes the browser tools and returns all the tools
-// ready to be added to an agent. It also returns a cleanup function that should
-// be called when done to properly close the browser.
+// RegisterBrowserTools returns all browser tools ready to be added to an agent.
+// It also returns a cleanup function that should be called when done to properly close the browser.
+// The browser will be initialized lazily when a browser tool is first used.
func RegisterBrowserTools(ctx context.Context, supportsScreenshots bool) ([]*llm.Tool, func()) {
browserTools := NewBrowseTools(ctx)
- // Initialize the browser
- if err := browserTools.Initialize(); err != nil {
- log.Printf("Warning: Failed to initialize browser: %v", err)
- }
-
return browserTools.GetTools(supportsScreenshots), func() {
browserTools.Close()
}