Repository navigation
Description
Original Request
CREATE When multiple images are streamed in either direction simultaneously, eg uploading 2+ images or when the model reads 2-3+ images very quickly, dreb RPC session can crash. It should not.
Summary
A dashboard-driven dreb session (RPC child process) can die when multiple images are in flight simultaneously — both when uploading 2+ images in a prompt and when the model reads 2-3+ images quickly in one turn. The in-flight turn is lost and the session shows as ended. Image payloads are large inline base64 blobs that cross the RPC stdout/stdin pipes in both directions at once, and the session's stdout write queue hits the 16 MiB backpressure guard that deliberately force-kills the process (process.exit(1)).
Current Behavior
- Attaching 2+ images to a dashboard prompt, or a turn where the agent reads 2-3+ images quickly (concurrent image tool results), can kill the session's RPC process mid-turn; the dashboard surfaces
RPC process exited (code 1, ...)and the turn's output is lost. - Images travel as inline base64 in both directions: the browser POSTs base64 in the prompt JSON body (25 MiB cap), the dashboard forwards them as a single JSONL line on the child's stdin, and image tool results come back as full base64 in stdout events (
tool_execution_end,message_end) and in full-transcriptget_messagesresponses. - While the dashboard process is busy (synchronous JSON parsing of multi-MiB lines, strict base64 decode + SHA-256 of each image, Photon preview decoding, or re-fetching full transcripts), the child's stdout backpressures; queued writes beyond 16 MiB (
MAX_QUEUED_STDOUT_BYTES) trip the guard inpackages/coding-agent/src/core/output-guard.ts, which writes a "Fatal: stdout write queue exceeded 16 MiB bytes..." diagnostic to stderr and callsprocess.exit(1). - Amplifier: with the "originals" tool-result image mode, the browser auto-fetches every tool-result image; each uncached fetch triggers a full-transcript
getMessages()round trip that re-transfers all image base64 over the same stdout pipe, concurrently with the live event stream.
Proposed Behavior
The RPC session must survive concurrent multi-image traffic in both directions. Attaching 2+ images to a prompt, and turns where the agent reads multiple images, must complete with the session alive — images delivered to the model and rendered per the configured image mode. Large in-flight image payloads must not force-kill the session.
Acceptance Criteria
- A prompt with 2+ attached images sent from the dashboard does not kill the session; the turn completes and the session remains usable.
- A turn in which the agent reads 2-3+ images quickly (concurrent image tool results) does not kill the session.
- An automated regression test exercises concurrent multi-image traffic through the dashboard RPC stack and asserts the session survives.
- No display regression: images continue to be delivered to the model and rendered per the configured tool-result image mode (placeholders / previews / originals).
Context
- Related prior work: Bound dashboard runtime events before RPC serialization #448 (bound dashboard runtime events before RPC serialization), Bound dashboard runtime events before RPC serialization #452 (PR that added the 16 MiB stdout queue guard), Bound dashboard streaming payloads for fast local models #445 (bound dashboard streaming payloads for fast local models), Bound flushRawStdout waiting on stalled print-mode pipes #453 (bound flushRawStdout on stalled pipes), Dashboard: low-data image mode — quantized thumbnails, HD toggle, SSE frame stripping #398 (dashboard low-data image mode), Dashboard discards image content blocks from tool results, so images never render inline #389 (dashboard discarded image content blocks from tool results), Keep agent running after image read on gpt-5.5 #283 (keep agent running after image read on gpt-5.5).
- No existing open issue covers concurrent multi-image RPC session crashes.
Technical Notes
- Upload path:
packages/dashboard/src/client/screens/session.tsx(base64 at send time) →api.ts(POST /api/runtimes/:key/promptwith inline{data, mimeType}) →packages/dashboard/src/server/server.ts(express.json25 MiB cap,parseImages) →packages/coding-agent/src/modes/rpc/rpc-client.ts(prompt/steer/followUpserialize one JSONL line on child stdin) →rpc-mode.ts(attachJsonlLineReader→session.prompt({images})). - Image return path:
packages/coding-agent/src/core/tools/read.ts(whole file → base64 →ImageContentin the tool result; 4.5 MiB base64 resize target, or uncapped whenimageAutoResize: false) →packages/agent/src/agent-loop.ts(message_start/message_endcarry the full tool result including base64) → stdout events keep base64 inline (rpc-event-projection.tsonly stripsmessage_updatecumulative fields) → dashboard server projects base64 →image_referencefor the browser (server.ts,dashboard-images.ts). - Crash guard:
packages/coding-agent/src/core/output-guard.ts— 16 MiB cap on queued stdout writes while backpressured → stderr diagnostic +process.exit(1); added in Bound dashboard runtime events before RPC serialization #452 to prevent unbounded growth after the Bound dashboard runtime events before RPC serialization #448 bursts. - Observability gap: the "Fatal: stdout write queue exceeded..." diagnostic goes to child stderr, but the surfaced session error is only
RPC process exited (code 1, signal null)(formatRpcExitinruntime-pool.ts); the stderr tail is only attached to 30 s request-timeout errors. - Secondary latent risk (possible separate issue):
RpcClientwrites child stdin with no'error'listener and no process installsuncaughtException/unhandledRejectionhandlers — an EPIPE on a dead child's stdin can kill the dashboard process itself (all sessions). Also: stdin JSONL lines are buffered as unbounded growing strings (jsonl.ts), and prompt images get only shape checks on the RPC side (no base64/mime validation).
Activity
Prevent dashboard RPC crashes from concurrent multi-MiB images (#495)
Prevent RPC session crashes on concurrent multi-image traffic (#496)