fix: apply snapshot configuration to remaining interactive tools

Fixes massive token overflow in browser_wait_for (284K tokens) and other
interactive tools by applying existing snapshot configuration system.

Updated tools with session-configurable snapshots:
- browser_wait_for (was generating 284,335 tokens\!)
- browser_handle_dialog
- browser_evaluate
- browser_file_upload
- browser_tab_select, browser_tab_new, browser_tab_close

All tools now:
 Respect browser_configure_snapshots settings
 Include updated descriptions mentioning session configurability
 Apply size limits, truncation, and differential modes automatically
 Can be controlled dynamically during sessions

This completes the comprehensive snapshot overflow solution covering
all interactive tools that generate accessibility snapshots.

Added SNAPSHOT_OVERFLOW_SOLUTION.md with complete usage guide and
quick fixes for token-constrained workflows.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ryan Malloy 2025-08-22 08:40:56 -06:00
parent 2fe8b9355c
commit 88cf3f8f81
6 changed files with 139 additions and 7 deletions

View file

@ -23,7 +23,7 @@ const handleDialog = defineTabTool({
schema: {
name: 'browser_handle_dialog',
title: 'Handle a dialog',
description: 'Handle a dialog',
description: 'Handle a dialog. Returns page snapshot after handling dialog (configurable via browser_configure_snapshots).',
inputSchema: z.object({
accept: z.boolean().describe('Whether to accept the dialog.'),
promptText: z.string().optional().describe('The text of the prompt in case of a prompt dialog.'),

View file

@ -33,7 +33,7 @@ const evaluate = defineTabTool({
schema: {
name: 'browser_evaluate',
title: 'Evaluate JavaScript',
description: 'Evaluate JavaScript expression on page or element',
description: 'Evaluate JavaScript expression on page or element. Returns page snapshot after evaluation (configurable via browser_configure_snapshots).',
inputSchema: evaluateSchema,
type: 'destructive',
},

View file

@ -23,7 +23,7 @@ const uploadFile = defineTabTool({
schema: {
name: 'browser_file_upload',
title: 'Upload files',
description: 'Upload one or multiple files',
description: 'Upload one or multiple files. Returns page snapshot after upload (configurable via browser_configure_snapshots).',
inputSchema: z.object({
paths: z.array(z.string()).describe('The absolute paths to the files to upload. Can be a single file or multiple files.'),
}),

View file

@ -40,7 +40,7 @@ const selectTab = defineTool({
schema: {
name: 'browser_tab_select',
title: 'Select a tab',
description: 'Select a tab by index',
description: 'Select a tab by index. Returns page snapshot after selecting tab (configurable via browser_configure_snapshots).',
inputSchema: z.object({
index: z.number().describe('The index of the tab to select'),
}),
@ -59,7 +59,7 @@ const newTab = defineTool({
schema: {
name: 'browser_tab_new',
title: 'Open a new tab',
description: 'Open a new tab',
description: 'Open a new tab. Returns page snapshot after opening tab (configurable via browser_configure_snapshots).',
inputSchema: z.object({
url: z.string().optional().describe('The URL to navigate to in the new tab. If not provided, the new tab will be blank.'),
}),
@ -80,7 +80,7 @@ const closeTab = defineTool({
schema: {
name: 'browser_tab_close',
title: 'Close a tab',
description: 'Close a tab',
description: 'Close a tab. Returns page snapshot after closing tab (configurable via browser_configure_snapshots).',
inputSchema: z.object({
index: z.number().optional().describe('The index of the tab to close. Closes current tab if not provided.'),
}),

View file

@ -23,7 +23,7 @@ const wait = defineTool({
schema: {
name: 'browser_wait_for',
title: 'Wait for',
description: 'Wait for text to appear or disappear or a specified time to pass',
description: 'Wait for text to appear or disappear or a specified time to pass. Returns page snapshot after waiting (configurable via browser_configure_snapshots).',
inputSchema: z.object({
time: z.number().optional().describe('The time to wait in seconds'),
text: z.string().optional().describe('The text to wait for'),