19. Deep Read: FileReadTool

What Makes FileReadTool Interesting

This is not a simple file read wrapper. It handles token-aware reading, image and PDF support, line-based reading, notebook conversion, memory freshness notes, blocked device paths, session-file analytics, and path normalization across platforms.

Important Design Choices

  • Dangerous pseudo-files such as /dev/zero and stdio aliases are blocked without reading them.
  • Large or rich files are handled according to file type instead of forcing one text-only path.
  • Read permissions are integrated with wildcard-based filesystem rules.
  • Reading is shaped for model consumption, not just for returning bytes.

Main Lesson

“Read file” in an agent product is really a content preparation pipeline. It must care about safety, token cost, file type, human readability, and future tool interactions.

Source Navigation

Recommended Source Files

  • source/tools/FileReadTool/FileReadTool.ts
  • source/tools/FileReadTool/limits.ts
  • source/tools/FileReadTool/prompt.ts
  • source/tools/FileReadTool/types.ts
  • source/Tool.ts

Next Files to Read

  • source/tools/FileEditTool/FileEditTool.ts
  • source/tools/FileEditTool/utils.ts
  • source/tools/GlobTool