Search

0007: Queue Inbound Sidecar Frames During HostCalls

On this page

Status: Proposed Date: 2026-06-25 Supersedes: N/A Superseded by: N/A

Context

The sidecar protocol multiplexes two flows on the child’s stdin: host requests to the extension and host responses to the extension’s HostCalls. A sidecar that waits for a HostCall response by matching only an id can accidentally discard host requests received in the same window.

This failure mode causes permanent deadlock: the host waits for a response to a request that the child already discarded.

Candidates

OptionProsCons
Queue non-matching inbound frames while awaiting HostCall responsesPreserves protocol ordering and avoids discarded host requestsRequires shared sidecar harness behavior and tests
Forbid HostCalls outside initializeSimpler runtime loopToo restrictive for LSP, lint, AST edits, and formatting
Use separate pipes for HostCalls and host requestsClear transport separationBreaks the current protocol shape and process harness

Decision

We will require sidecars that make HostCalls to queue inbound host requests encountered while awaiting a HostCall response. Queued frames are replayed FIFO after the HostCall response is handled.

Initialize-time HostCalls should complete before the extension sends Initialized, so the host does not hand normal control to a child that is not yet back in its main read loop. New long-lived HostCall paths must include parallel stress tests with at least 20 concurrent iterations.

Consequences

What becomes easier:

  • Sidecars can safely perform HostCalls during tool execution and event handling.
  • Concurrent spawn and push-response races are covered by regression tests.
  • The protocol hazard is documented close to the architectural decision.

What becomes harder:

  • Sidecar loops need queueing logic instead of simple id-only response waits.
  • Tests must cover concurrency windows that are otherwise rare.

Constitution Compliance

PrincipleStatusJustification
Extension fault isolationCompliantProtocol stalls are handled as sidecar concerns, not host failures.
CorrectnessCompliantHost requests are not silently discarded.
VerificationCompliantThe decision requires stress coverage for new HostCall paths.

View original on GitHub