Skip to content

A bash flood is SIGKILLed at the output cap but reported to the model as success #181

Closed

Description

@pdettori

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:

  1. On cap trip, the transport kills the child and resolves with exitCode: null (packages/k8s-sandbox/src/exec.ts, mirroring grpc-relay-transport.ts's long-standing behavior). null is the deliberate signal for "no real exit status".
  2. Pi's bash tool treats a null exit code as non-failing: pi-fork/packages/coding-agent/src/core/tools/bash.ts:397 is if (exitCode !== 0 && exitCode !== null) { throw ... }.
  3. createPodBashOps returns 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

  1. 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 changes GrpcRelayTransport's behavior, which has resolved-with-marker since ST3.
  2. Add a truncated flag to ExecInPod's return type. Cleanest semantically — callers decide what truncation means for them, and createPodBashOps can surface it as a failure while readFile keeps its own guard. Cost: a seam change touching SandboxTransport, all three implementations, the conformance battery, and every call site.
  3. 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) in exec.ts that 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions