GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): refresh MCP tools before session snapshots by Dante-dan · Pull Request #54942 · anomalyco/opencode

Conversation

@Dante-dan

@Dante-dan Dante-dan commented Oct 12, 2026 •
edited by opencode-agent Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #54794

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Refresh the connected MCP tool inventory before a session takes its tool snapshot. Previously, flush only waited for initial registration; an ACP-resumed turn could miss an already-connected tool while its catalog update waited in the 100ms debounce and produce a false removal notice. The refresh shares the reconciliation lock and skips unchanged inventories.

How did you verify your code works?

  • The new registry regression fails with the previous initial-only flush and passes with this change, without advancing the debounce timer.
  • packages/core: bun run test test/mcp.test.ts --timeout 30000 — 78 passed, 1 failed. The failure was terminates MCP descendants after the wrapper exits successfully hitting its internal 3s timeout.
  • With Node 24 and dependencies hydrated from the existing lockfile, the targeted rerun of the new catalog regression, notification coalescing and descendant cleanup test passed 3/3.
  • packages/core: bun run typecheck passed; affected-file formatting and git diff --check passed.
  • Root lint passed with Node 24. The full monorepo typecheck encountered sandboxed Astro telemetry writes and then a missing aws4fetch dependency in the console app; affected-core typechecking passed.
  • The author's native ACP/real-model reproduction was not run; this validates the stale connected-catalog boundary.

Screenshots / recordings

No UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #39902

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Dante-dan
fix(core): refresh MCP tools before session snapshots
706bad7
@github-actions

github-actions Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

opencode-agent[bot]
opencode-agent Bot reviewed Oct 12, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks sound to me, and I have no blocking concerns.

How I checked it: the new regression test fails on the base and passes with this PR. test/mcp.test.ts has one failure, the descendant-cleanup timeout, and the base has the same one. Session tests and the packages/core type check pass. I could not run the ACP resume reproduction from #54794, because it needs the free hosted model, which rejects local builds, and a mock provider does not trigger the race. So I have only verified the fix at the registry level, not end to end over ACP.

On cost: flush runs before every step, and it now takes the reconcile lock and calls MCP.tools(). That is an in-memory read, so the extra work per step is small. The unchanged-list check by reference (===) is correct, because entries are only replaced with new objects when the server re-lists its tools.

Public API: unchanged.

Overlap: #52214 (open) adds a separate refresh that the MCP add/remove/connect/disconnect routes await, and it keeps flush limited to waiting for the initial registration. Folding the refresh into flush, as this PR does, also covers those routes for the next session snapshot, so the two PRs should be reconciled before both land.

Related: #39902

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@geoff-ux geoff-ux mentioned this pull request Oct 16, 2026
First prompt after start has no MCP tools: tool list does not wait for pending MCP connections #51812
Closed
This was referenced Oct 16, 2026
Direct MCP tools (codemode: false) are nondeterministically missing from the session toolset; opencode run can hang forever after a session error #56240
Closed
mcp: stale tool binding after moving a session's directory; not repaired by service restart #56374
Closed
@opencodejr opencodejr Bot mentioned this pull request Oct 31, 2026
run builds the first model request before a codemode: false remote MCP server's tools are available (tools missing from first request) #60893
Closed
@neriousy

neriousy commented Nov 5, 2026

Copy link
Copy Markdown
Member

Thanks for tracking this down, @Dante-dan. Your diagnosis was right: the resumed turn's tool snapshot ran before the 100 ms debounced MCP reload, so a reconnected tool showed up as removed.

The same fix has since landed on dev in #60490. McpTool.flush now compares mcp.tools() with what the registry holds and reconciles when they differ, after briefly waiting for servers that are still starting. We ran your "refreshes a resumed MCP catalog before the debounced notification" test on current dev; the only change was adding awaitStartup: () => Effect.void to the mock. It passes there and fails with the old flush. An ACP subprocess check (cold session/resume with the same MCP server) also passes.

This branch now conflicts with dev and is far behind, so I'm closing it as superseded by #60490. Thanks again for the contribution!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@neriousy neriousy closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

ACP resume sometimes marks a reattached MCP tool as removed

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Dante-dan @neriousy
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.