Skip to content

mcpx(plugin): a transient daemon failure arms the 60s miss-cooldown — forget() stamps missedAt, so the next call never rediscovers a healthy daemon (v2 tools.ts, ported from v1) #2557

Closed

Description

@dezren39

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
    • :143 discoveryRetryMs = options.discoveryRetryMs ?? TUNING.missCooldownMs (60_000, pkgs/mcpx/plugin/opencode/mcpx/daemon.ts:65)
    • :196 look() returns a synthetic { candidates: [], rung: 6, reason: "none" } while Date.now() - missedAt < discoveryRetryMs — without calling discoverFn
    • :213 a genuine no-target discovery stamps missedAt (the intended cooldown)
    • :226-229 forget() also stamps missedAt = Date.now()
    • :245-247 viaDaemon's catch calls forget() 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):

  1. mcpx_exec succeeds — discoverFn called once.
  2. The client's exec throws once ("daemon went away") — the tool call rejects, viaDaemon forgets.
  3. The daemon is healthy again; the next mcpx_exec returns mcpx: no daemon is reachable and no mcpx binary could be run… and discoverFn is 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 same look(), so the plugin reports "none" about a healthy daemon.
  • With MCPX_PLUGIN_DISCOVERY_RETRY set 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.ts as well — or the issue records why v1 is excluded.
  • A regression test in v2/tools.test.ts exercises the transient-failure path with the default (non-zero) discoveryRetryMs: fail once, succeed on the very next call, with discoverFn called 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

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 30, 2026
  2. dezren39 commented on Oct 30, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 1, 2026
  4. 5 remaining items

  5. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    work/assignedQueue worker lifecycle state
    on Nov 1, 2026
  6. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    agent-note:v1 — state: picked-up (small_fix task 5370, OpenChamber scheduled lane)

  7. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    agent-note:v1 — state: handed-off (task 5370, OpenChamber scheduled lane)

  8. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    agent-note:v1 — state: done (queue task 5370, outcome pr_opened)

  9. added
    task/fixhas a fix task queued
    and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/fixhas a fix task queued

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions