Skip to content

Prevent RPC session crashes when multiple images are in flight simultaneously #495

Closed

Description

@aebrer

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-transcript get_messages responses.
  • 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 in packages/coding-agent/src/core/output-guard.ts, which writes a "Fatal: stdout write queue exceeded 16 MiB bytes..." diagnostic to stderr and calls process.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

Technical Notes

  • Upload path: packages/dashboard/src/client/screens/session.tsx (base64 at send time) → api.ts (POST /api/runtimes/:key/prompt with inline {data, mimeType}) → packages/dashboard/src/server/server.ts (express.json 25 MiB cap, parseImages) → packages/coding-agent/src/modes/rpc/rpc-client.ts (prompt/steer/followUp serialize 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 → ImageContent in the tool result; 4.5 MiB base64 resize target, or uncapped when imageAutoResize: false) → packages/agent/src/agent-loop.ts (message_start/message_end carry the full tool result including base64) → stdout events keep base64 inline (rpc-event-projection.ts only strips message_update cumulative fields) → dashboard server projects base64 → image_reference for 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) (formatRpcExit in runtime-pool.ts); the stderr tail is only attached to 30 s request-timeout errors.
  • Secondary latent risk (possible separate issue): RpcClient writes child stdin with no 'error' listener and no process installs uncaughtException/unhandledRejection handlers — 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

  1. added
    bug
    P1
    dashboard
    on Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1bugdashboard

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions