Skip to content

Commit 5fe1d69

Browse files
RayCharlizardclaude
andcommitted
docs(learnings): apply review fixes from #527
- Fix `LocalAgentModeSessions` IPC namespace: add missing `_$_` separator (was `claude.web_$_LocalAgentModeSessions_*`, should be `claude.web_$_LocalAgentModeSessions_$_*`). Verified against the channel names in the actual minified source. - Add back the `Logs prefix` column (`[CCD]` / `[LAM]`) the original issue body had — these are the literal grep targets in `~/.config/Claude/logs/` for confirming the bug hit. - Re-route the secondary upstream venue from `anthropics/claude-code` to `anthropics/claude-agent-sdk-typescript`. The SDK transport (`spawnLocalProcess` / `Du.spawn`) lives in the SDK's own public repo (issues enabled); pointing at `claude-code` while saying the CLI isn't on the spawn path is the exact contradiction the warning paragraph below it tries to prevent. - Workaround note: reclaim a stale lock via `rename()` over the path, not `unlink()` then re-open. Heads off the obvious-but-racy port for anyone copying the pattern. Co-Authored-By: Claude <claude@anthropic.com>
1 parent bc7ca5b commit 5fe1d69

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

docs/learnings/mcp-double-spawn.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ external services with single-connection contracts, etc.
4040
Two parallel session managers live inside Electron main, each
4141
holding an independent Claude Agent SDK `query`:
4242

43-
| Manager class | IPC namespace | Coordinator |
44-
|--------------------------|----------------------------------------|-------------------|
45-
| `LocalSessions` | `claude.web_$_LocalSessions_$_*` | `n2t("ccd")` |
46-
| `LocalAgentModeSessions` | `claude.web_$_LocalAgentModeSessions_*`| `n2t("cowork")` |
43+
| Manager class | IPC namespace | Coordinator | Logs prefix |
44+
|--------------------------|------------------------------------------|-----------------|-------------|
45+
| `LocalSessions` | `claude.web_$_LocalSessions_$_*` | `n2t("ccd")` | `[CCD]` |
46+
| `LocalAgentModeSessions` | `claude.web_$_LocalAgentModeSessions_$_*`| `n2t("cowork")` | `[LAM]` |
47+
48+
The logs prefixes are what to grep `~/.config/Claude/logs/` for to
49+
confirm a session is hitting both coordinators (and therefore this
50+
bug specifically).
4751

4852
Each `query` holds its own SDK transport. The transport's
4953
`spawnLocalProcess` (`Du.spawn`) launches stdio MCPs **without
@@ -98,6 +102,9 @@ can defend themselves:
98102
1. **Lockfile + staleness check.** `fs.openSync('wx')` with PID,
99103
verified live via `process.kill(pid, 0)`. The second instance
100104
detects a live owner and backs off, or reclaims a stale lock.
105+
Reclaim atomically — write the new lock to a temp path and
106+
`rename()` over the stale one, never `unlink()` then re-open
107+
(a third instance can win the gap).
101108
2. **Idempotent state writes.** Resolve target files/keys from
102109
the incoming message payload rather than from in-process
103110
state, so two instances writing the same broadcast end up at
@@ -113,9 +120,10 @@ The reporter's `baro-voyager` MCP shipped both in commit
113120
`support@anthropic.com`. The duplication happens in
114121
closed-source Desktop main.
115122
- **Secondary:** an SDK-transport-flavored issue on
116-
`anthropics/claude-code` is defensible — the spawn path goes
117-
through the **Claude Agent SDK's** `query` transport, which is
118-
shared surface area with the CLI. Reference the missing `hZ`
123+
[`anthropics/claude-agent-sdk-typescript`](https://github.com/anthropics/claude-agent-sdk-typescript)
124+
is defensible — the spawn path goes through the **Claude Agent
125+
SDK's** `query` transport (`spawnLocalProcess` / `Du.spawn`),
126+
which is shared surface area. Reference the missing `hZ`
119127
consultation explicitly.
120128

121129
The embedded Claude Code CLI subprocess inside Claude Desktop is

0 commit comments

Comments
 (0)