Skip to content

fix(tools): portable base64 encoding for image reading on macOS#5657

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
CharlieKerfoot:mac-img-reading
Apr 6, 2026
Merged

fix(tools): portable base64 encoding for image reading on macOS#5657
teknium1 merged 1 commit intoNousResearch:mainfrom
CharlieKerfoot:mac-img-reading

Conversation

@CharlieKerfoot
Copy link
Copy Markdown
Contributor

Problem

_read_image() in tools/file_operations.py called base64 -w 0 to
produce unwrapped base64 output. The -w 0 flag is GNU coreutils syntax
and is not supported by macOS base64. On macOS with the local terminal
backend this caused every read_file call on an image to fail silently
(exit code != 0), returning a generic error instead of the base64 content.
Docker/Modal/SSH backends running Linux were unaffected.

Fix

Replaced base64 -w 0 <path> with base64 <path> | tr -d '\n'.

Both GNU and macOS base64 wrap output by default; piping through
tr -d '\n' strips the newlines without needing any platform detection.
This is portable across all terminal backends (local macOS, local Linux,
Docker, Modal, SSH to macOS or Linux hosts).

Testing

On macOS with the local terminal backend:

  1. hermes chat -q "Read this image: /path/to/some/image.png"
  2. Verify the agent receives base64 content instead of a read error

@teknium1 teknium1 merged commit 3b4dfc8 into NousResearch:main Apr 6, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants