Skip to content

fix(agents): read oversized single-line files without exec - #126587

Merged
steipete merged 1 commit into
mainfrom
steipete/wonderful-greider-42952b
Aug 20, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/wonderful-greider-42952b

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users reading minified JSON, generated data, or other files containing a single line larger than 50 KiB received none of that line. The read result instead recommended a Bash pipeline, which dead-ended agents whose tool surface intentionally omitted exec/process.

Why This Change Was Made

The canonical read owner now returns a bounded UTF-8/UTF-16-safe slice plus a flat intra-line cursor, while existing offset/limit line paging remains unchanged. OpenClaw's adaptive wrapper chooses the context-derived byte budget and aggregates canonical pages without exceeding the complete model-visible cap, including continuation guidance.

Known skill instruction paths remain whole-document-only: window parameters are rejected, fitting instructions are delivered in full, and oversized instructions return a bounded refusal without leaking a misleading partial document. The Codex app-server filesystem contract was inspected directly and remains path-only/full-byte; model-visible slicing stays owned by OpenClaw.

Production growth is +408/-133 (net +275). The remaining growth is the explicit cursor contract, bounded-page owner, adaptive continuation metadata, and whole-instruction policy; the obsolete shell fallback was removed. Tests are +315/-44 (net +271).

User Impact

Agents can now inspect large single-line files through read alone, including on exec-disabled surfaces. Repeated cursor reads reconstruct the original content exactly without splitting multibyte UTF-8 characters or UTF-16 surrogate pairs, and every result remains within its hard context budget.

Skill and playbook-style instruction documents are never presented as a partial first window that could be mistaken for the complete guidance.

Evidence

Before the fix, a 51,470-byte one-line JSON file returned only:

[Line 1 is 50.3KB, exceeds 50.0KB limit. Use bash: sed ... | head -c 51200]

with zero output lines and no usable read continuation.

After the fix:

  • node scripts/run-vitest.mjs src/agents/sessions/tools/read.test.ts src/agents/agent-tools.create-openclaw-coding-tools.test.ts src/agents/filesystem-tools-output-contract.test.ts — 169 tests passed.
  • node scripts/check-changed.mjs -- <8 changed files> — formatting, core/test types, lint, dead exports, import cycles, database/storage, plugin-boundary, and repository guards passed.
  • pnpm build — full build passed; no ineffective dynamic import warning.
  • Direct assembled-tool proof with exec and process absent reconstructed an 81,936-byte minified JSON file in 3 bounded reads and a 98,316-byte emoji line in 4 bounded reads. Each result was at most 32 KiB and contained no Bash/sed/head guidance.
  • Structured autoreview: clean, no accepted/actionable findings.

AI-assisted: yes. I reviewed the implementation, ownership boundary, tests, dependency contract, and proof results.

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 20, 2026 07:43
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 20, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head c67602c31f63ae4db4504e4b91d36a8b6bc7507b:

  • Focused owner/assembly/output-contract proof: node scripts/run-vitest.mjs src/agents/sessions/tools/read.test.ts src/agents/agent-tools.create-openclaw-coding-tools.test.ts src/agents/filesystem-tools-output-contract.test.ts — 169 tests passed.
  • Changed gate: node scripts/check-changed.mjs -- <8 changed files> — format, core/test types, lint, dead exports, import cycles, database/storage, plugin-boundary, and repository guards passed.
  • Build: pnpm build — passed; no ineffective dynamic import warning.
  • Direct behavior proof: an exec/process-disabled assembled tool surface reconstructed an 81,936-byte minified JSON line in 3 bounded reads and a 98,316-byte astral-emoji line in 4 bounded reads. Every result stayed at or below 32 KiB and contained no Bash/sed/head guidance.
  • Structured autoreview: no accepted/actionable findings.
  • Native review artifacts: validated READY FOR /prepare-pr, zero findings.
  • Exact-head CI: green — https://github.com/openclaw/openclaw/actions/runs/32345357265

Codex dependency contract was inspected directly: app-server fs/readFile accepts only an absolute path and returns the complete base64 bytes, so OpenClaw remains the owner of bounded model-visible slicing.

The latest ClawSweeper comment is still the in-progress placeholder and contains no findings or Rank-up moves: list to apply or skip. Per the repository review policy, the queued publisher is not a merge blocker once exact-head CI and the independent review gates are green.

@steipete
steipete merged commit 5066bd7 into main Aug 20, 2026
288 of 289 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant