Files
magpie/docs
yetone 98955300a7 claude: no request-sized value on a run's command line or in its environment (#6848)
recih (on X) ran a long Claude Code session through the Claude
subscription's interactive mode on a Linux server: every start, the
resume and the replay alike, failed "fork/exec <magpie>: argument list
too long", 8 502s, and every request after. Linux starts nothing with one
argument or variable over 128KiB (MAX_ARG_STRLEN), and startRun put the
conversation's safeguards in CLAUDE_CODE_EXTRA_BODY whole and the JSON
schema in --json-schema whole.

Now no value of a request's goes on the command line or in the
environment over claudetui.StartValueMax (16KiB, under Windows' 32K
variable too):
- interactive mode: CLAUDE_CODE_EXTRA_BODY is a stand-in
  (startSafeguards: all when they fit, else without the parts Claude
  Code itself sheds, else []); guard.json keeps them whole and tap.js
  puts them in each request, as before. tap.js no longer sets the
  variable to a file over the bound, since Claude Code's MCP servers
  and tools inherit it. It is given no --json-schema (it never used it;
  the answer tool has the schema).
- -p: a schema over the bound goes with the initialize request
  (jsonSchema, as the Agent SDK sends it). Claude Code passes over an
  initialize schema it can't use silently, so such a schema is compiled
  first and refused with a 400, as the flag's exit was (#3036).
Other per-request starts checked (warmups, usage, sign-ins, other
agents' bridges): nothing request-sized on argv or env.

Run:
- TestClaudeTUIStartBounded, TestClaudePrintStartBounded,
  TestClaudePrintSchemaPlaces (gateway) and
  TestTapPutsSafeguardsTooLargeForTheEnvironment (claudetui, bun and
  node): red on the old code on mote (152KB env, 277KB arg, 502 for a
  bad large schema, 204KB variable left by tap.js), and on Linux
  (wsl-run, magpie-desktop) the old code failed with the real
  "fork/exec .../magpie: argument list too long" and the tap's child
  start with E2BIG. All green on the new code on mote and Linux.
- Real claude 2.1.316: an initialize jsonSchema answered
  structured_output {"city":"Paris"} (haiku); CLAUDE_CODE_EXTRA_BODY
  {"safeguards":[]} is sent as "safeguards":[] in every request (local
  listener, sandbox config).
- gofmt; go vet (darwin, GOOS=linux, GOOS=windows) on the two packages;
  go test -tags nogui ./internal/claudetui ./internal/gateway on mote:
  ok claudetui 182.5s, ok gateway 1066.8s (at base e25210b6e). Rebased
  on aa3307585: the four new tests plus the guard, safeguards and
  schema tests of both packages again, ok.
- Full suite (go test -tags nogui -timeout 45m ./... on mote): not
  finished at push; its result goes on #6848.

Not tried: the reporter's own session; a real interactive run with
safeguards over 16KiB end to end (the tap is tested with a FetchSession
stub); a Claude Code the helper gives no tap (a path with whitespace)
now sends the bounded stand-in instead of all the safeguards.
2026-11-16 19:18:49 +08:00
..