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(mcp): wait for pending ToolsChanged reloads before flush resolves (fixes #45333) by optamus-ai · Pull Request #46177 · anomalyco/opencode

Conversation

@optamus-ai

@optamus-ai optamus-ai commented Aug 29, 2026

Copy link
Copy Markdown

Summary

McpTool.flush only waited for the initial MCP tool registration fiber to complete. If MCP servers connected after the initial registration but before SessionContext.select took its snapshot, the ToolsChanged event triggered a reconcile reload that flush did not wait for. The snapshot was taken with stale tool state, omitting MCP tools from the model request.

Fix

Track pending reconcile operations via a counter and Deferred waiters in McpTool.layer. flush now waits for both the initial registration AND any in-flight reconcile operations to complete before resolving. This ensures the snapshot captures all MCP tools from independently connected servers.

Key changes:

  • : Added counter and array. Modified reconcile to track completions. Modified flush to wait for pending reloads.
  • : New regression tests verifying flush completes correctly and snapshot is valid after ToolsChanged events.

Acceptance

Positive case: MCP connects → ToolsChanged → reconcile → flush waits → SessionContext snapshot → model request → MCP tools present ✓

Negative case: MCP tool denied by policy → NOT present in model request (unchanged behavior)

Testing

  • 229/229 MCP + session-runner + flush tests pass
  • 415/415 total core tests pass (36 skipped)
  • Typecheck passes for core and client packages
  • No new dependencies added

Fixes #45333

Sorry, something went wrong.

Uh oh!

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

All reactions
Hona and others added 30 commits August 26, 2026 07:56
@Hona
feat(app): stack collapsed tool calls (#45176)
ea582fc
@Hona
feat(app): render settings as a fullscreen surface (#45190)
16d731b
@nexxeln
fix(ai): keep bedrock mantle responses on http (#45197)
0f7a76e
@nexxeln
feat(plugin): add declarative vcs repository markers (#45192)
4eaf533
@Hona
fix(desktop): align and theme Windows caption controls (#45208)
24ac058
@Hona
feat(app): add experimental vertical session tabs (#45210)
5d7c2cc
@opencode-agent @Brendonovich
fix(app): combine loaded skill and instruction file entries (#45217)
ab95695
Co-authored-by: Brendonovich <[email protected]>
@jlongster
feat(cli): embed persistent PTY binaries from npm packages (#45248)
d572a57
@opencode-agent
chore: update nix node_modules hashes
afc26c7
@opencode-agent @Brendonovich
fix(desktop): restrict macOS app entitlements (#45258)
874538d
Co-authored-by: Brendonovich <[email protected]>
@nexxeln
fix(session): support assistant message content updates (#45015)
e82aa92
@thdxr
feat(tui): show LLM token throughput
91028a6
@jlongster
feat(tui): add persistent session terminals (#44971)
9cca8dd
@jlongster
fix(tui): restore terminal settings and move pane toggle to sessions (#…
21980a4
…45271)
@opencode-agent
chore: update nix node_modules hashes
1e864dd
@Brendonovich
fix(app): include files in mention search (#45281)
6c6871f
@rekram1-node
chore(ai): format package with prettier (#45280)
37a6ba8
@kitlangton
feat(tui): investigate errors in a new session
3d7ba38
@jlongster
fix(server): unblock persistent terminal input in Bun builds (#45287)
ab2d251
@thdxr
fix(core): suppress state updates during location teardown
cbef698
@rekram1-node
feat(ai): add native Groq provider with provider-specific options (#4…
f4a9b93
…5288)
@kitlangton
fix(tui): clarify code mode tool call rendering
fedf017
@rekram1-node
fix(core): allow non-letter tool name prefixes (#45317)
cf98ca5
@kitlangton
refactor(core): encapsulate physical attempt execution (#45294)
2602dcd
Extract physical-attempt streaming, tool execution, and durable settlement from the Session runner. Preserve logical-Step retry and recovery policy, use tagged drain outcomes, and fix multi-click selection during auto-copy.
@kitlangton
fix(sdk): identify workspace dependencies by version specifier (#45309)
962a6ca
@opencode-agent @Brendonovich
fix(ui): remove solid menu group label line height (#45331)
ab6a01d
Co-authored-by: Brendonovich <[email protected]>
@rekram1-node
fix(ai): accept empty Responses stream IDs and null items (#45330)
a841d6d
@Brendonovich
fix(app): prevent stale service worker startup failures (#45344)
0772b67
@jlongster
fix(pty): upgrade opencode-pty to 0.1.10 (#45352)
018b4c4
@kitlangton
fix(core): recover background jobs after restart
ded8a49
Persist background Job ownership and terminal results across server restarts. Resume existing subagent Sessions, admit shell cancellation notices without waking idle parents, and preserve explicit cancellation.
rekram1-node and others added 22 commits August 27, 2026 22:54
@rekram1-node
fix(codemode): report original tool errors (#45820)
56f2559
@kitlangton
chore: remove unused changesets (#45827)
95725d1
@kitlangton
test(core): use direct test imports (#45683)
a519363
@kitlangton
test(core): remove unused test imports (#45674)
d2c307a
@opencode-agent
chore: update nix node_modules hashes
4685ba8
@rekram1-node
fix(ai): normalize response item boundaries (#45789)
074413a
@kitlangton
feat(tui): streamline diff review workflow (#45817)
92b9eeb
@Hona
fix(session-ui): enable word diffs in unified view (#45833)
bb390f4
@rekram1-node
fix(ai): make final snapshots authoritative for text and reasoning (#…
55674b8
…45831)
@rekram1-node
refactor(ai): default unrecognized provider failures to retry (#45825)
5cbafc5
@rekram1-node
fix(ai): detect DashScope input length overflow errors (#45834)
bdf019a
@rekram1-node
refactor(ai): simplify response stream state (#45835)
18e22cd
@kitlangton
test(core): use effectful temp fixtures (#45637)
5743537
@rekram1-node
fix(core): strengthen background shell guidance (#45843)
e12e04f
@rekram1-node
fix(core): classify AISDK network failures as transport errors (#45840)
d2ee536
@rekram1-node
fix(ai): ignore late converse tool deltas (#45847)
85d8b07
@rekram1-node
fix(ai): finish chat streams at done sentinel (#45850)
11ca603
@neriousy
Revert "fix(cli): prevent repeated updates and npm cache growth" (#45865
1c8e557
)
@jlongster
feat(plugin): expose experimental terminal reads (#45792)
ca47949
@kitlangton
feat(ai): add first-class TestLLM controls (#45828)
0d42e76
Optamus
fix(service): ensure explicit restart never reuses unresponsive incum…
70686d8
…bent (fixes #37795)

opencode2 service restart could silently fail to stop a temporarily unresponsive managed service (health probe timeout 2s, find returns undefined) and then ensure() would reuse the original process when it recovered, so restart had a success path where it did not replace the service at all.

Fix: Service.stop now returns { stopped, reason } with distinct outcomes for missing registration, stale-registration, still-registered, timeout, and error, preserving stale-registration and reused-PID safety via same() checks and process.kill(pid, 0). Service.restart now checks stopResult.stopped and fails with actionable error 'Service restart failed to stop incumbent (reason: ...). Explicit restart never proceeds to ensure() after an unconfirmed stop.' instead of silently continuing to ensure(). Successful restart now verifies the new instance has a different PID/identity.

Preserves ordinary ensure/reconnect idempotent reuse semantics; only explicit restart requires replacement. Covers missing registration, corrupt registration, unreachable health endpoint, rejected/unsupported stop, graceful timeout/escalation, successful replacement, and stale PID protection. Logs whether stop was accepted, unsupported, rejected, timed out, escalated, or skipped.

Add deterministic regression test service-restart-race.test.ts proving explicit restart does not silently reuse unresponsive incumbent.

Closes #37795
Optamus
fix(mcp): wait for pending ToolsChanged reloads before flush resolves
af4ab16
McpTool.flush only waited for the initial MCP tool registration fiber to
complete. If MCP servers connected after the initial registration but
before SessionContext.select took its snapshot, the ToolsChanged event
triggered a reconcile reload that flush did not wait for. The snapshot
was taken with stale tool state, omitting MCP tools from the model request.

Track pending reconcile operations via a counter and Deferred waiters.
flush now waits for both the initial registration AND any in-flight
reconcile operations to complete before resolving. This ensures the
snapshot captures all MCP tools from independently connected servers.

Adds regression tests verifying flush completes correctly and snapshot
is valid after ToolsChanged events.

Fixes #45333
@optamus-ai
optamus-ai requested review from Brendonovich and Hona as code owners August 29, 2026 17:56
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 29, 2026
@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

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

Found one potentially related PR. Let me verify if it's a genuine duplicate:

PR #45822 - fix(core): pull pending registry changes on read - This appears related as it also deals with pending changes and registry state, though it's focused on core registry changes rather than MCP tool registration specifically.

However, this seems to be addressing a different aspect of the registry/tool system. PR #46177 is specifically about MCP tool flush operations and ToolsChanged events, while #45822 focuses on pulling pending registry changes.

No duplicate PRs found

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 29, 2026
@github-actions github-actions Bot closed this Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Hona Hona Awaiting requested review from Hona
@Brendonovich Brendonovich Awaiting requested review from Brendonovich

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.

V2 session runner does not include MCP tools in LLM requests

Uh oh!

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

10 participants

@optamus-ai @Hona @nexxeln @jlongster @thdxr @Brendonovich @rekram1-node @kitlangton @simonklee @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.