perf(daemon-client): persistent remote clients re-run the /health probe on every command

Open
#2,650 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
cli, performance

Research direction

Start in src/daemon-client/daemon-client-lifecycle.ts at ensureRemoteDaemon and trace how persistent clients identify a daemon and handle transport failures. Run the persistent-client benchmark and daemon-client-health-compat.test.ts first. Done means one wire request per command after the initial probe, restart detection still passes, and fresh-process CLI behavior is unchanged.

Written by the indexing model from the issue text.

Description

enhancement

Problem

ensureRemoteDaemon (src/daemon-client/daemon-client-lifecycle.ts:174) calls readRemoteDaemonHealth on every sendToDaemon, so one proxied command is two round trips:

GET  /health
POST /rpc

For a fresh-process CLI that is one probe per process and unavoidable. For a persistent client (the MCP server, the benchmark's persistent-client mode) it is a full extra round trip per command. It matches the ~2.5 round trips per snapshot the #2198 slice-B benchmark measured (persistent-client medians 36 / 93 / 233 ms at 0 / 20 / 80 ms RTT).

Found in #2381 while asserting #2198's round-trip line in #2387; it predates the bridge and is unrelated to it.

Required behavior

A persistent client pays the ADR 0006 health probe once per daemon identity, not once per command. A fresh process still probes before its first command. Re-probe on a transport failure or a changed daemon identity (base URL, token, pid), not on a timer alone.

Completion

  • Persistent-client benchmark shows one wire request per command after the first.
  • A daemon restart between two commands is still detected (compat and version-skew checks in daemon-client-health-compat.test.ts keep passing).
  • Fresh-process CLI behavior unchanged.
Dominant language
TypeScript
Stars
4.7k
Forks
304
Avg merge
11h 46m
Merged PRs (30d)
471

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from callstack/agent-device

All issues in callstack/agent-device

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.