Alloy.Tool.Core.Read (alloy v0.16.0)

Copy Markdown View Source

Built-in tool: read files with line numbers.

Returns file contents formatted as line_number\tcontent (matching cat -n output). Supports pagination via :offset (1-based) and :limit parameters, defaulting to the first 2,000 lines. Output stops at a whole line before max_result_chars/0; whenever lines remain, it ends with [Showing lines X-Y of N. Use offset=Z to continue.].

Binary files (a NUL byte in the first 8KB) are refused.

Usage

config = %{tools: [Alloy.Tool.Core.Read], ...}

The agent can then call:

%{file_path: "lib/app.ex", offset: 10, limit: 50}