Containarium icon indicating copy to clipboard operation
Containarium copied to clipboard

box runs: serve a structured_output run's stderr through the API

Open hsinatfootprintai opened this issue 2 weeks ago • 1 comments

Problem. A run started with StartBoxRunRequest.structured_output writes only the engine's JSON result object to <run_name>.log. Stderr goes to <run_name>.stderr.log, which TailBoxRunLog does not serve (box_run.proto, structured_output comment). When the engine fails before it writes a result object (expired sign-in, network error, crash), the log is empty and the caller has no way to read why. A plain-text run shows the same error inline. So a caller that turns on structured_output to get BoxRun.usage (#3467) loses the error text for exactly the runs that need it.

Expected. A caller can read a structured run's stderr through the daemon API, the same way it reads the log.

Possible shapes (maintainer's choice):

  1. A TailBoxRunLogRequest.stream field (STDOUT default, STDERR) that tails <run_name>.stderr.log with the same offset and window rules. Advertised as a capability (e.g. box_run_stderr).
  2. Once the run has exited, BoxRun carries a bounded tail of stderr (e.g. the last 4 KiB) when the result object is missing or invalid.

Acceptance

  • A structured run whose engine exits non-zero without writing a result object: the caller can read the engine's error text through the API.
  • A plain-text run is unchanged.
  • A daemon without the capability behaves as today, and a caller can tell the two apart from SystemInfo.capabilities.

Related: #3467 (usage for structured-output runs), #3743 (usage for plain-text runs).

hsinatfootprintai avatar Nov 16 '26 13:11 hsinatfootprintai

Starting on this with shape 1: a TailBoxRunLogRequest.stream enum (LOG default, STDERR) that tails <run_name>.stderr.log with the same offset/window/follow/ended rules, advertised as box_run_stderr. The response also echoes the stream it read, so the CLI (code logs --stderr) and the MCP code_logs tool can refuse a window from an older daemon that ignored the field instead of showing the run's log as stderr.

NopeCharon avatar Nov 19 '26 22:11 NopeCharon