@@ -21,6 +21,10 @@ function isOversizedReadPlaceholder(content: string): boolean {
2121 )
2222}
2323
24+ function hasImageAttachment ( result : { attachment ?: { type ?: string } } ) : boolean {
25+ return result . attachment ?. type === 'image'
26+ }
27+
2428export async function executeVfsGrep (
2529 params : Record < string , unknown > ,
2630 context : ExecutionContext
@@ -153,8 +157,9 @@ export async function executeVfsRead(
153157 const uploadResult = await readChatUpload ( filename , context . chatId )
154158 if ( uploadResult ) {
155159 if (
156- isOversizedReadPlaceholder ( uploadResult . content ) ||
157- serializedResultSize ( uploadResult ) > TOOL_RESULT_MAX_INLINE_CHARS
160+ ! hasImageAttachment ( uploadResult ) &&
161+ ( isOversizedReadPlaceholder ( uploadResult . content ) ||
162+ serializedResultSize ( uploadResult ) > TOOL_RESULT_MAX_INLINE_CHARS )
158163 ) {
159164 return {
160165 success : false ,
@@ -183,8 +188,9 @@ export async function executeVfsRead(
183188 const fileContent = await vfs . readFileContent ( path )
184189 if ( fileContent ) {
185190 if (
186- isOversizedReadPlaceholder ( fileContent . content ) ||
187- serializedResultSize ( fileContent ) > TOOL_RESULT_MAX_INLINE_CHARS
191+ ! hasImageAttachment ( fileContent ) &&
192+ ( isOversizedReadPlaceholder ( fileContent . content ) ||
193+ serializedResultSize ( fileContent ) > TOOL_RESULT_MAX_INLINE_CHARS )
188194 ) {
189195 return {
190196 success : false ,
@@ -214,8 +220,9 @@ export async function executeVfsRead(
214220 return { success : false , error : `File not found: ${ path } .${ hint } ` }
215221 }
216222 if (
217- isOversizedReadPlaceholder ( result . content ) ||
218- serializedResultSize ( result ) > TOOL_RESULT_MAX_INLINE_CHARS
223+ ! hasImageAttachment ( result ) &&
224+ ( isOversizedReadPlaceholder ( result . content ) ||
225+ serializedResultSize ( result ) > TOOL_RESULT_MAX_INLINE_CHARS )
219226 ) {
220227 return {
221228 success : false ,
0 commit comments