You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend the existingread_file tool so it windows like Grok Build’s read_file. Do not add a second tool.
Grok Build today:
Arg
Meaning
path / target_file
required
offset
1-based start line (default 1)
limit
number of lines to return (default 1000)
Result is a line-numbered window (N→content), not a byte range and not a prefix-from-start dump.
Invincible today (lib/agent/tools.ts → client.readFile(path, maxBytes) → BYO sandbox/tools.mjs / Vercel lib/sandbox/vercelClient.ts): path + optional maxBytes prefix, 16 MiB hard cap, no line addressing. A truncated read does not authorize str_replace / overwrite (fileFreshnesstruncated: true).
This issue locks the window shape that #563 left as “pick in plan”: line offset + limit, same names and defaults as Grok Build. #563’s “don’t dump a huge file when no window” is the default-limit=1000 case.
Desired behavior (lock)
Same args and defaults as Grok Build:
read_file { path, offset?, limit? }
offset — first line to return, 1-based. Omit / 1 = start of file.
limit — max lines to return. Omit = 1000.
Response body is the window only, each line prefixed with its file line number so the next call can pass offset without guessing (Grok Build uses N→line; pick that or N|line in implement — one format, documented).
Status line stays the first line / L1 brief source and must name the window, e.g. read_file lib/foo.ts offset=40 limit=20 lines=412 (truncated): (exact string locked in implement). salientToolBits must keep L1 as path + size, not the body.
maxBytes stays as a safety cap on the returned window (still server-capped at 16 MiB). It is not the window API.
Unchanged jail / cwd / in-jail absolute rules. finalize / TOOL_RESULT_MAX_CHARS still apply to the window.
Window covers the entire file (returned line count < limit, and not byte-truncated)
truncated: false
authorized (same as today’s full read)
Hit limit or maxBytes
truncated: true
denied — existing “truncated read_file is not enough”
No silent “windowed is full enough.” To edit a 1400-line file the model raises limit (or pages, then requests a limit that covers the file). Do not add a full: true flag unless a later plan proves default-1000 makes grants impossible in practice.
Caps (NEW — generous defaults; any change to 16 MiB is a human decision)
Cap
Value
Notes
Default limit
1000 lines
Grok Build default. NEW.
offset
≥ 1
1-based. Out of range → empty window + truncated/lines= so the model can recover, not a crash.
maxBytes / 16 MiB
unchanged
Still the hard read/write byte ceiling.
Layers
Concern
Layer
Path
Tool schema + status line + freshness
Vercel backend
lib/agent/tools.ts, lib/agent/fileFreshness.ts
BYO read
sandbox daemon
sandbox/tools.mjsreadFileTool — today fh.read(..., 0) prefix only
Vercel sandbox read
backend
lib/sandbox/vercelClient.ts
L1 brief
backend
lib/agent/agentStream.tssalientToolBits
Living doc
docs
docs/sandbox.md (read_file row), docs/harness-limits.md if a cap is listed
Do not load 16 MiB into the model to return 40 lines. Daemon/client may scan to line offset; the tool result must be the window only. Protocol bump only if the BYO /v1/read_file body must grow (offset/limit) — lock in implement; additive fields preferred.
Summary
Extend the existing
read_filetool so it windows like Grok Build’sread_file. Do not add a second tool.Grok Build today:
path/target_fileoffsetlimitResult is a line-numbered window (
N→content), not a byte range and not a prefix-from-start dump.Invincible today (
lib/agent/tools.ts→client.readFile(path, maxBytes)→ BYOsandbox/tools.mjs/ Vercellib/sandbox/vercelClient.ts):path+ optionalmaxBytesprefix, 16 MiB hard cap, no line addressing. A truncated read does not authorizestr_replace/ overwrite (fileFreshnesstruncated: true).This issue locks the window shape that #563 left as “pick in plan”: line
offset+limit, same names and defaults as Grok Build. #563’s “don’t dump a huge file when no window” is the default-limit=1000case.Desired behavior (lock)
Same args and defaults as Grok Build:
offset— first line to return, 1-based. Omit /1= start of file.limit— max lines to return. Omit = 1000.offsetwithout guessing (Grok Build usesN→line; pick that orN|linein implement — one format, documented).read_file lib/foo.ts offset=40 limit=20 lines=412 (truncated):(exact string locked in implement).salientToolBitsmust keep L1 as path + size, not the body.maxBytesstays as a safety cap on the returned window (still server-capped at 16 MiB). It is not the window API.Unchanged jail / cwd / in-jail absolute rules.
finalize/TOOL_RESULT_MAX_CHARSstill apply to the window.Edit gate (do not weaken #277)
freshness.recordReadstr_replace/ overwritelimit, and not byte-truncated)truncated: falselimitormaxBytestruncated: trueNo silent “windowed is full enough.” To edit a 1400-line file the model raises
limit(or pages, then requests a limit that covers the file). Do not add afull: trueflag unless a later plan proves default-1000 makes grants impossible in practice.Caps (NEW — generous defaults; any change to 16 MiB is a human decision)
limitoffsettruncated/lines=so the model can recover, not a crash.maxBytes/ 16 MiBLayers
lib/agent/tools.ts,lib/agent/fileFreshness.tssandbox/tools.mjsreadFileTool— todayfh.read(..., 0)prefix onlylib/sandbox/vercelClient.tslib/agent/agentStream.tssalientToolBitsdocs/sandbox.md(read_file row),docs/harness-limits.mdif a cap is listedDo not load 16 MiB into the model to return 40 lines. Daemon/client may scan to line
offset; the tool result must be the window only. Protocol bump only if the BYO/v1/read_filebody must grow (offset/limit) — lock in implement; additive fields preferred.Acceptance
read_fileacceptsoffset+limitwith Grok Build defaults (1/1000)offset=40, limit=20returns file lines 40–59 onlymaxBytes/ redact /finalizeunchangeddocs/sandbox.md(and limits table if needed) describe the window — timeless, no issue theaterNon-goals
read_range,read_window, …)list_dirintoreadstr_replace/write_filematch semanticsexec sedas the product pathRelated
str_replacewindow: agent tool: stale/failed str_replace returns a small file window #564lib/agent/tools.tsread_file,sandbox/tools.mjsreadFileTool,lib/sandbox/vercelClient.tsreadFile