Repository navigation
Description
Summary
In the mcpx opencode plugin, one transient daemon failure suppresses daemon rediscovery for the whole miss-cooldown (60s by default) — even when a daemon is healthy again immediately. The failure path and the no-daemon path share the same missedAt stamp, so the cooldown written for "no daemon exists on this machine" also applies to "a daemon existed and just hiccuped".
Present in both trees (same code shape, ported):
- v2:
pkgs/mcpx/plugin/opencode/v2/tools.ts:143discoveryRetryMs = options.discoveryRetryMs ?? TUNING.missCooldownMs(60_000,pkgs/mcpx/plugin/opencode/mcpx/daemon.ts:65):196look()returns a synthetic{ candidates: [], rung: 6, reason: "none" }whileDate.now() - missedAt < discoveryRetryMs— without callingdiscoverFn:213a genuine no-target discovery stampsmissedAt(the intended cooldown):226-229forget()also stampsmissedAt = Date.now():245-247viaDaemon's catch callsforget()under the comment "Stopped, restarted, or its socket moved. Forget it; the next call asks again." — but the next call does not ask again until the cooldown expires
- v1:
pkgs/mcpx/plugin/opencode/mcpx-session.ts:249,257,265-267,348— identical pattern and identical comment.
Note the inconsistency that gives the intent away: the daemon_forget tool (v2 tools.ts:437-439) clears found directly without stamping missedAt, so a user-initiated forget rediscovers immediately, while an error-initiated forget waits out the cooldown.
Verified (this run, main 069aff5)
Laptop Bun probe (~/git/fleet/probe-2026-10-29-laneB-forgetcool/, real v2/tools.ts/remember.ts/daemon.ts, md5-matched to main; stub storage/discover/client in the style of tools.test.ts), runtime created with no discoveryRetryMs (production default):
mcpx_execsucceeds —discoverFncalled once.- The client's
execthrows once ("daemon went away") — the tool call rejects,viaDaemonforgets. - The daemon is healthy again; the next
mcpx_execreturnsmcpx: no daemon is reachable and no mcpx binary could be run…anddiscoverFnis still at 1 call — rediscovery never ran.
The existing rediscovery-precedence test (v2/tools.test.ts, "a session choice survives a transient failure") only passes because it sets discoveryRetryMs: 0, sidestepping the interaction.
Why it matters
- After any daemon restart/blip, every mcpx tool call for up to 60s either spawns the CLI fallback (the ~135x-slower path the ladder exists to avoid, per
daemon.ts's header) — and the CLI walks its own ladder, so it can answer from a different daemon than the session's chosen one — or, with no binary available, fails outright with a misleading "no daemon is reachable" while one is running. daemon_status/annotation()go through the samelook(), so the plugin reports "none" about a healthy daemon.- With
MCPX_PLUGIN_DISCOVERY_RETRYset longer, the blind window grows proportionally.
Acceptance criteria
- After a transient daemon error, the next tool call re-runs discovery immediately (a restarted/healthy daemon is picked up on the first call after the failure), while a genuine no-target discovery still arms the miss cooldown so daemon-less machines don't rescan on every call.
- The fix lands in the v2 tree and, if triage judges the ported flaw in scope, in v1
mcpx-session.tsas well — or the issue records why v1 is excluded. - A regression test in
v2/tools.test.tsexercises the transient-failure path with the default (non-zero)discoveryRetryMs: fail once, succeed on the very next call, withdiscoverFncalled again. - The "next call asks again" comment and the behavior agree.
Dedup: #2309 is goDurationMs returning Infinity for overflow durations (the retry value itself), distinct from this forget/cooldown conflation at the default value. #1858 is the v2 port tracker.
Activity
dezren39 commentedon Oct 30, 2026
🤖 Agent note · filed
5 remaining items
dezren39 commentedon Nov 2, 2026
agent-note:v1 — state: picked-up (small_fix task 5370, OpenChamber scheduled lane)
dezren39 commentedon Nov 2, 2026
agent-note:v1 — state: handed-off (task 5370, OpenChamber scheduled lane)
bun test pkgs/mcpx/plugin/opencode— 89 pass, 5 skipped; focused v2 suite — 36 pass;git diff --check— pass.dezren39 commentedon Nov 2, 2026
agent-note:v1 — state: done (queue task 5370, outcome pr_opened)