You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: FileSystem.read_file_structured returns empty images for internal image files and replace_file_str fails on binary files #6115
When binary/image files (PngFile, GifFile, JpgFile, JpegFile, WebpFile via Base64BinaryFile) are created in the agent's file system (e.g. via write_file tool):
FileSystem.read_file_structured() does not return the image data in result['images']. Instead, it treats the binary file as text, extracting file_obj.read() (the summary stub [binary <ext> file, <N> bytes]) and returning {'message': ..., 'images': None}. Consequently, when the agent invokes read_file on an internal image, the vision model receives no image payload in ActionResult.images.
FileSystem.replace_file_str() does not guard against Base64BinaryFile. It attempts string replacement on the stub description and passes it to file_obj.write(), which fails with a base64 validation error rather than cleanly explaining that binary files cannot have text replaced.
Current Behavior
Calling await fs.read_file_structured('test.png') on an internal PNG file returns {'message': 'Read from file test.png.\n<content>\n[binary png file, 68 bytes]\n</content>', 'images': None}.
Calling await fs.replace_file_str('test.png', 'old', 'new') on an internal binary file attempts to validate the description string as base64 and raises/returns: Error: content for 'test.png' is not valid base64....
Expected Behavior
Calling await fs.read_file_structured('test.png') on an internal image file should populate result['images'] = [{'name': file_obj.full_name, 'data': file_obj.content}] and set result['message'] = 'Read image file test.png.', matching external image reads so read_file supplies images to the vision model.
Calling await fs.replace_file_str('test.png', 'old', 'new') should cleanly return Error: Cannot replace text in binary file 'test.png'. Overwrite it instead., matching Base64BinaryFile.append_file_content.
In read_file_structured(), lines 844-868 currently state # For internal files, only non-image types are supported and call file_obj.read(). For Base64BinaryFile, content is base64 string, so read_file_structured() should set result['images'] = [{'name': file_obj.full_name, 'data': file_obj.content}].
In replace_file_str(), lines 949-960 perform string replacement and rewrite the file without checking isinstance(file_obj, Base64BinaryFile).
Activity