Repository navigation
Description
Problem
With the output cap now enforced on KubectlTransport (added while closing epic #89, so the cap is a seam property rather than a gRPC-only one), a bash whose stdout crosses 8 MiB is SIGKILLed mid-flight — and the model is told it succeeded.
Three facts compose:
- On cap trip, the transport kills the child and resolves with
exitCode: null(packages/k8s-sandbox/src/exec.ts, mirroringgrpc-relay-transport.ts's long-standing behavior).nullis the deliberate signal for "no real exit status". - Pi's bash tool treats a null exit code as non-failing:
pi-fork/packages/coding-agent/src/core/tools/bash.ts:397isif (exitCode !== 0 && exitCode !== null) { throw ... }. createPodBashOpsreturns only{ exitCode }and discards stdout entirely (packages/k8s-sandbox/src/operations.ts:82).
So a verbose build or test run that legitimately emits >8 MiB is killed partway and presented to the model as a completed command.
The cap also buys nothing on this path in exchange. The 8 MiB we buffered is thrown away at (3), and Pi separately clips model-visible output to 50 KB / 2000 lines (pi-fork/packages/coding-agent/src/core/tools/truncate.ts). The context-flooding threat the cap exists to mitigate is already handled downstream for bash; here the cap only kills the command and misreports it.
Documented in spec §8's "Accepted divergences" as a known hazard pending this decision. Found by the whole-branch review of the epic-closing work.
The decision — three shapes, each with a real cost
- Make truncation reject rather than resolve. Simple and truthful. But it contradicts spec §8's stated contract ("truncates, appends
[output truncated], and surfaces the marker to Pi") and changesGrpcRelayTransport's behavior, which has resolved-with-marker since ST3. - Add a
truncatedflag toExecInPod's return type. Cleanest semantically — callers decide what truncation means for them, andcreatePodBashOpscan surface it as a failure whilereadFilekeeps its own guard. Cost: a seam change touchingSandboxTransport, all three implementations, the conformance battery, and every call site. - Do not cap the bash path at all. Justified by the fact that stdout is discarded there anyway, so the cap has no protective value. Cost: reinstates unbounded buffering on that path — the original
TODO(M3)inexec.tsthat closing Epic: SandboxTransport — language-neutral remote sandbox exec over gRPC #89 removed.
Option 2 is the only one that lets the two paths differ correctly (bash wants to fail; a whole-file read wants to fail; a streamed grep may want the marker), which is an argument for paying its cost once.
Note on scope
This is not reachable on the gRPC path in a new way — GrpcRelayTransport has always resolved with exitCode: null on cap trip, so the false-success shape predates this work there. What changed is that it now also applies to the default in-cluster pod path.
Refs
Epic #89 · spec §8 "Accepted divergences" · related #180 (the uncapped third transport).
Activity
test(k8s-sandbox): seed the live-smoke fixtures in a beforeAll
fix(k8s-sandbox): make a broken output-cap stage loud instead of silent
docs(specs): ST6 — seam-wide output cap + explicit truncation contract
feat(k8s-sandbox): represent truncation explicitly on the SandboxTran…
fix(k8s-sandbox): name truncation precisely in readFile and glob
fix: report truncation as truncation at the grep and diff-capture sites
docs: the output cap is now a seam-wide guarantee
test(k8s-sandbox): live gate for the capped read path
fix: address final whole-branch review findings
fix(k8s-sandbox): report a cap-truncated bash as exit 137, not success
docs(spec): close #182's accepted divergence in §8 and ADR-0024