@@ -1069,6 +1069,42 @@ describe("createAITools filesystem tools", () => {
10691069 } ) ;
10701070 } ) ;
10711071
1072+ it ( "recognizes message-only missing media errors" , async ( ) => {
1073+ const store = memoryStore ( { size : 2 } ) ;
1074+ store . readChunks = ( ) => ( {
1075+ [ Symbol . asyncIterator ] ( ) {
1076+ return this ;
1077+ } ,
1078+ async next ( ) : Promise < IteratorResult < Uint8Array > > {
1079+ throw new Error ( "ENOENT: no such file or directory" ) ;
1080+ } ,
1081+ } ) ;
1082+ const tool = createReadTool ( { store, maxModelBytes : 4 } ) ;
1083+ const output = await executeTool ( tool , { path : "/workspace/image.png" } ) ;
1084+
1085+ await expect ( modelOutput ( tool , { path : "/workspace/image.png" } , output ) ) . resolves . toEqual ( {
1086+ type : "error-text" ,
1087+ value : "Could not read file bytes: /workspace/image.png" ,
1088+ } ) ;
1089+ } ) ;
1090+
1091+ it ( "does not confuse unrelated no-such errors with missing media" , async ( ) => {
1092+ const failure = new Error ( "SQLITE_ERROR: no such table: vfs_chunks" ) ;
1093+ const store = memoryStore ( { size : 2 } ) ;
1094+ store . readChunks = ( ) => ( {
1095+ [ Symbol . asyncIterator ] ( ) {
1096+ return this ;
1097+ } ,
1098+ async next ( ) : Promise < IteratorResult < Uint8Array > > {
1099+ throw failure ;
1100+ } ,
1101+ } ) ;
1102+ const tool = createReadTool ( { store, maxModelBytes : 4 } ) ;
1103+ const output = await executeTool ( tool , { path : "/workspace/image.png" } ) ;
1104+
1105+ await expect ( modelOutput ( tool , { path : "/workspace/image.png" } , output ) ) . rejects . toBe ( failure ) ;
1106+ } ) ;
1107+
10721108 it ( "does not hide unrelated inline media read failures" , async ( ) => {
10731109 const failure = new Error ( "storage unavailable" ) ;
10741110 const store = memoryStore ( { size : 2 } ) ;
0 commit comments