FileReadTool: add EISDIR handling with helpful suggestion (like ENOENT)

Resolved 💬 2 comments Opened Apr 3, 2026 by kyzzen Closed May 12, 2026

Problem

When the model calls Read on a directory path, it gets a raw EISDIR error:

EISDIR: illegal operation on a directory, read '/path/to/dir'

This gives the model no guidance on what to do instead. Compare to the ENOENT case, which helpfully suggests similar filenames and paths under cwd — EISDIR gets no equivalent nudge.

Evidence

From analyzing 391K hook payloads captured via PostToolUseFailure over 87 days:

  • 158 EISDIR errors across 23 projects
  • All from Read tool — the model tries to read a directory to see its contents
  • The model usually recovers by trying ls or Glob on the next turn, but the wasted tool call adds latency and context

Suggested improvement

When the Read tool detects EISDIR, return an actionable error message instead of the raw errno:

'/path/to/dir' is a directory, not a file. Use the Glob tool to find files by pattern, or Bash: ls -la '/path/to/dir'

This matches the existing pattern where ENOENT errors are converted into helpful suggestions for the model.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗