Skip to content

fix(adapters): read files over commands in 512 KiB pieces - #137

Merged
reachjalil merged 1 commit into
pre-releasefrom
fix/shellcmd-chunked-reads
Nov 21, 2026
Merged

reachjalil merged 1 commit into
pre-releasefrom
fix/shellcmd-chunked-reads

Conversation

@reachjalil

Copy link
Copy Markdown
Member

shellcmd.ReadFile, the file read for backends whose only primitive is "run a command" (gcp-sandboxes, agentcore, northflank), returned the whole file as base64 in one command's output. Agent Platform's :execute answers are capped near 1 MB, by a third party's measurement; Google documents no limit. So on gcp-sandboxes any file over about 750 KB failed, as provider_unavailable (a 502). This was a leftover from the review of that adapter in #135.

Change

  • Reads now go in 512 KiB pieces, under 700 KB of output each, using head -c and then dd bs=512K skip=N count=1.
  • The first command also prints the file's size (wc -c), so a file up to 512 KiB still takes a single command.
  • A file whose size changes during the read is refused with sandbox_failed rather than spliced from two versions.
  • Writes were already chunked (64 KiB) and are unchanged.
  • The image now also needs head, dd and wc, which GNU coreutils and BusyBox both provide.

Tests: run against a local /bin/sh.

  • Files of 2 pieces plus a remainder, exactly one piece, and exactly two pieces: each checks the command count and that the largest answer stays under 800 KB.
  • A file that grows between pieces.
  • The three adapters' own tests pass.
  • make verify passes.

Not run against Agent Platform, AgentCore or Northflank.

🤖 Generated with Claude Code

shellcmd.ReadFile returned a whole file as base64 in one command's output.
Agent Platform's :execute answers are capped near 1 MB (a third party's
measurement), so a file over about 750 KB failed there; agentcore and
northflank read the same way. Reads now go in 512 KiB pieces (under 700 KB
of output each): the first command also prints the size, so a small file
still takes one command, and a file whose size changes while it is read is
refused instead of spliced.

Tested with a local shell; not run against the backends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jalil <reachjalil@gmail.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI passed at c85c766.

@reachjalil
reachjalil merged commit 9fd3ce5 into pre-release Nov 21, 2026
23 checks passed
@reachjalil
reachjalil deleted the fix/shellcmd-chunked-reads branch November 21, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant