File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,15 @@ export class VisibleTextTool extends BrowserToolBase {
50
50
}
51
51
return text . trim ( ) ;
52
52
} ) ;
53
- return createSuccessResponse ( `Visible text content:\n${ visibleText } ` ) ;
53
+ // Truncate logic
54
+ const maxLength = typeof args . maxLength === 'number' ? args . maxLength : 20000 ;
55
+ let output = visibleText ;
56
+ let truncated = false ;
57
+ if ( output . length > maxLength ) {
58
+ output = output . slice ( 0 , maxLength ) + '\n[Output truncated due to size limits]' ;
59
+ truncated = true ;
60
+ }
61
+ return createSuccessResponse ( `Visible text content:\n${ output } ` ) ;
54
62
} catch ( error ) {
55
63
return createErrorResponse ( `Failed to get visible text content: ${ ( error as Error ) . message } ` ) ;
56
64
}
@@ -170,7 +178,13 @@ export class VisibleHtmlTool extends BrowserToolBase {
170
178
) ;
171
179
}
172
180
173
- return createSuccessResponse ( `HTML content:\n${ htmlContent } ` ) ;
181
+ // Truncate logic
182
+ const maxLength = typeof args . maxLength === 'number' ? args . maxLength : 20000 ;
183
+ let output = htmlContent ;
184
+ if ( output . length > maxLength ) {
185
+ output = output . slice ( 0 , maxLength ) + '\n<!-- Output truncated due to size limits -->' ;
186
+ }
187
+ return createSuccessResponse ( `HTML content:\n${ output } ` ) ;
174
188
} catch ( error ) {
175
189
return createErrorResponse ( `Failed to get visible HTML content: ${ ( error as Error ) . message } ` ) ;
176
190
}
You can’t perform that action at this time.
0 commit comments