@@ -41,7 +41,7 @@ Screenshots help you see what's on the page and make better decisions.`,
4141 try {
4242 // Check if model has enough tokens for screenshots
4343 const maxTokens = executionContext . messageManager . getMaxTokens ( )
44- const MIN_TOKENS_FOR_SCREENSHOTS = 128000 // 128k minimum
44+ const MIN_TOKENS_FOR_SCREENSHOTS = 64000 // 128k minimum
4545
4646 if ( maxTokens < MIN_TOKENS_FOR_SCREENSHOTS ) {
4747 Logging . log ( 'ScreenshotTool' ,
@@ -73,16 +73,16 @@ Screenshots help you see what's on the page and make better decisions.`,
7373
7474 const page = await executionContext . browserContext . getCurrentPage ( )
7575 if ( ! page ) {
76- const error = 'No active page found to take screenshot'
77- Logging . log ( 'ScreenshotTool' , error , 'error ')
78- return JSON . stringify ( toolError ( error ) )
76+ Logging . log ( 'ScreenshotTool' , 'No active page found to take screenshot' , 'error' )
77+ executionContext . messageManager . addAI ( 'Screenshot unavailable - no active page. Continuing without visual verification. ')
78+ return JSON . stringify ( toolSuccess ( 'Screenshot unavailable. Proceeding without visual capture.' ) )
7979 }
8080
8181 const screenshotDataUrl = await page . takeScreenshot ( selectedSize )
8282 if ( ! screenshotDataUrl ) {
83- const error = 'Failed to capture screenshot - no data returned'
84- Logging . log ( 'ScreenshotTool' , error , 'error ')
85- return JSON . stringify ( toolError ( error ) )
83+ Logging . log ( 'ScreenshotTool' , 'Failed to capture screenshot - no data returned' , 'error' )
84+ executionContext . messageManager . addAI ( 'Screenshot capture failed. Continuing without visual verification. ')
85+ return JSON . stringify ( toolSuccess ( 'Screenshot unavailable. Proceeding without visual capture.' ) )
8686 }
8787
8888 Logging . log ( 'ScreenshotTool' ,
@@ -101,11 +101,8 @@ Screenshots help you see what's on the page and make better decisions.`,
101101 } catch ( error ) {
102102 const errorMessage = error instanceof Error ? error . message : String ( error )
103103 Logging . log ( 'ScreenshotTool' , `Error capturing screenshot: ${ errorMessage } ` , 'error' )
104-
105- executionContext . getPubSub ( ) . publishMessage (
106- PubSub . createMessageWithId ( PubSub . generateId ( 'ToolError' ) , `Screenshot failed: ${ errorMessage } ` , 'error' )
107- )
108- return JSON . stringify ( toolError ( errorMessage ) ) // Return raw error
104+ executionContext . messageManager . addAI ( 'Screenshot capture failed. Continuing without visual verification.' )
105+ return JSON . stringify ( toolSuccess ( 'Screenshot unavailable. Proceeding without visual capture.' ) )
109106 }
110107 }
111108 } )
0 commit comments