Skip to content

agent tool: windowed read_file — don’t dump huge files #563

Description

@btipling

Summary

read_file should support a byte/line window (start / limit or equivalent) and must not dump a huge file into the model when no window is given.

Today: full file up to 16 MiB, then TOOL_RESULT_MAX_CHARS flatten. Large sources blow the turn; the model re-reads them next turn anyway because we drop tool_run (#549 — different issue).

Goal

  • Args: existing path + window (line start/limit or byte range — pick one in plan, name the cap).
  • Over a size/line threshold and no window: return {truncated/summarized, line_count or bytes, hint: request a window}not the body.
  • Optional later: language-agnostic outline. Do not ship Orrery’s Go-only func/type/package heuristic.
  • Successful windowed read still counts as a full-enough grant for str_replace only if we can define that honestly (or require a full read for edit — lock in plan). Do not silently weaken read-before-edit (plan: agent read-before-edit + external file freshness (parent) #277).

Success: reading ui.zig does not inject 1400 lines unless the model asked for a slice.

Constraints

  • Jail / cwd / in-jail abs unchanged.
  • finalize / TOOL_RESULT_MAX_CHARS still apply to the window.
  • Truncated-without-window must not authorize overwrite (freshness.recordRead(..., truncated: true) already exists).
  • Caps: NEW window default + “too big” threshold in create-plan.

Non-goals

Related

Suggested next

create-plan after #562’s result shape so search hits and read windows use the same line addressing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsandboxAgent sandbox / workspace (BYO + Vercel Sandbox backends)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions