You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(opencode): sessions without T3 MCP no longer get PR tool instructions - #35657
In the OpenCode v2 adapter, prepareTurn already left out the orchestration guidance when T3's MCP tools were not registered (an external Server URL, or a failed mcp.add). It still called buildRuntimeInstructions without pullRequestLinking, so the <pull_request_linking> block telling the agent to call link_pull_request, watch_pull_request and unwatch_pull_request went into the session instructions on every turn even though those tools did not exist. The fix passes pullRequestLinking: mcpAvailable, the same flag the orchestration guidance uses. The ACP adapter passes this option the same way. One call site changed, no new parser or regex. The two tests on factory/repro-35588 (external server, and MCP add failed) fail without the fix and pass with it. The bug was reproduced with those tests, not against a live external OpenCode server.
Commit 932cbd4 (origin/main). Started OpenCode 2.2.7 (@opencode/cli) as an independent server: opencode serve --hostname 127.0.0.1 --port 49374 with isolated XDG config/data dirs. Started T3 with T3CODE_DEV_SEED=0 vp run dev and paired the preview browser. In Settings > Providers > Add provider I added an OpenCode instance and set Binary path, Server URL http://127.0.0.1:49374 and the server password. In a new thread I chose Claude Haiku 5.5 on that provider and sent one message asking the agent to list its tools whose names contain pull_request. The turn completed. On the OpenCode server, GET /api/mcp?location[directory]=<thread dir> returned data: [], so no T3 MCP was registered. GET /api/experimental/session/<id>/instructions/entries returned key t3-code, containing <runtime_info> and the full <pull_request_linking> block (link_pull_request, watch_pull_request, unwatch_pull_request, 'no sleep, loops ... for PR waits') and no orchestration guidance. The agent replied: "I don't have any tools with "pull_request" in their name, so the list is empty." On branch factory/repro-35588 (5a23f69), two tests in OpenCode2AdapterV2.test.ts fail on main with an instructions-frame mismatch: the external-server case and the existing MCP-add-failed case. Passing pullRequestLinking: mcpAvailable makes all 158 tests in the file pass; that fix is not on the branch.
Evidence
Evidence: configure an external OpenCode 2.2.7 provider on each fresh T3 server, run the same tool-list request, then inspect the completed conversation and OpenCode's session instructions. Both sessions have an empty MCP list. Base includes mandatory PR-tool instructions; head omits them while retaining runtime information.
AI-assisted; verified with the tests and tools listed above. No tests were used as proof.
Not shown:
Failed MCP registration on a T3-managed OpenCode server was not exercised; this proof covers the external Server URL path.
Tests
vp test run src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts (apps/server): without the fix, 2 failed and 156 passed (the two repro tests); with the fix, 158 passed. vp run check:changed: format, lint, knip, graphql, typecheck (10 packages) and tests (2 files, 160 tests) all passed.
AI-assisted; verified with the tests and tools listed above.
Reproduces #35588: an external OpenCode server (and a failed MCP add)
leaves T3's MCP tools unregistered, yet the session's t3-code
instructions still require link_pull_request and watch_pull_request.
AI-assisted; verified with the tests and tools listed above.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Macroscope's review found this PR approvable — OpenCode sessions without T3 MCP will no longer receive instructions to invoke unavailable PR tools. Sessions with MCP retain their existing guidance, keeping the change narrowly scoped.
No code changes detected at ab693a8. Prior analysis still applies.
You can add or adjust custom eligibility rules. Learn more.
No actionable comments were generated in the recent review.
Walkthrough
The OpenCode adapter now passes MCP availability to runtime instruction construction. Tests cover the disabled pull request linking option during MCP re-registration and an external-server session that writes runtime instructions and completes a turn.
Changes: Runtime instruction availability
Layer / File(s)
Summary
Set and verify instruction availability packages/provider-opencode/src/server/v2/adapter.ts, apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
prepareTurn passes mcpAvailable as pullRequestLinking. Tests cover MCP re-registration and verify that an external-server session writes runtime instructions and completes a turn.
OpenCode sessions without T3 MCP tools will stop being told to call unavailable PR tools. The change is small and covered by tests, and no merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: sessions without T3 MCP no longer receive PR tool instructions. It follows the conventional commit form and matches the changeset, which passes pullRequestLinking: mcp…
Description check
The description follows the template well. It states the problem and the change, and it gives a scope section that links issue #35588 as the bug report. Verification is detailed, with test counts befo…
Linked Issues check
Issue #35588 is closed and completed. It supplies background only. No active directly linked target remains, so no linked-issue coding requirements apply. For reference, the whole-PR diff from merge b…
Out of Scope Changes check
The whole-PR diff from merge base 613d1ac to head ab693a8 touches two files. adapter.ts has the single call-site change that passes pullRequestLinking: mcpAvailable. OpenCode2AdapterV2.test.ts updat…
Full details: Title check
Explanation
The title names the main change: sessions without T3 MCP no longer receive PR tool instructions. It follows the conventional commit form and matches the changeset, which passes pullRequestLinking: mcpAvailable in the OpenCode v2 adapter.
Full details: Description check
Explanation
The description follows the template well. It states the problem and the change, and it gives a scope section that links issue #35588 as the bug report. Verification is detailed, with test counts before and after the fix, reproduction steps, and evidence. It is a little long and includes a non-template reproduction section, but all required sections are substantively complete.
Full details: Linked Issues check
Explanation
Issue #35588 is closed and completed. It supplies background only. No active directly linked target remains, so no linked-issue coding requirements apply. For reference, the whole-PR diff from merge base 613d1ac to head ab693a8 changes one call site in packages/provider-opencode/src/server/v2/adapter.ts. prepareTurn now passes pullRequestLinking: mcpAvailable to buildRuntimeInstructions, the same flag that gates the orchestration guidance. This matches the expected behavior in #35588. The external-server trust boundary is unchanged. The test file adds 'gives an external server's session no instructions for T3 tools it lacks' and updates the existing MCP re-registration expectation to pullRequestLinking: false. The PR description says the existing MCP-add-failed test also fails without the fix and passes with it. That test is not changed in this diff, so its coverage rests on the author's test report. This does not affect the verdict.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff from merge base 613d1ac to head ab693a8 touches two files. adapter.ts has the single call-site change that passes pullRequestLinking: mcpAvailable. OpenCode2AdapterV2.test.ts updates one expectation to pullRequestLinking: false and adds one external-server test. Both changes connect directly to the reported instruction mismatch. The PR objectives mention an ACP adapter that already passes the option. No ACP file appears in the reviewed diff, so no out-of-scope code is introduced. The PR images and transcripts are evidence material and not repository changes.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.
The automated pipeline stopped on this pull request and will not merge it:
these checks fail on ab693a8, also when run again: Test Server 3, and the rework changed nothing:
No code change was needed. Item 1 (buildRuntimeInstructions called without pullRequestLinking: false) describes the code before this fix: at ab693a8, prepareTurn in packages/provider-opencode/src/server/v2/adapter.ts passes pullRequestLinking: mcpAvailable, so the <pull_request_linking> block is omitted whenever T3's MCP tools are unavailable. That covers both external servers and failed MCP registration, in the same way t3OrchestrationSystemPrompt is already gated. OpenCode2AdapterV2.test.ts asserts this: the MCP-unavailable case expects pullRequestLinking: false, and a new external-server case expects the same. Item 2 (Test Server 3 failed): CI's only failing test was apps/server/src/mcp/TaskCancelUsageLimit.integration.test.ts, which hit the 120s timeout. That test covers Claude delegated-task usage-limit cancellation and runs no OpenCode code. Locally it passed 4 out of 4 runs on this head, about 12s each. Recent main commits pass Test Server 3, so this was a CI timeout on that run, not caused by the change. A rerun of the job should clear it. The 'Check' job's only annotation was its own exit code 1.
It stays open for a person to finish or close.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:XS0-9 changed lines (additions + deletions).vouch:trustedPR author is trusted by repo permissions or the VOUCHED list.
1 participant
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.
In the OpenCode v2 adapter, prepareTurn already left out the orchestration guidance when T3's MCP tools were not registered (an external Server URL, or a failed mcp.add). It still called buildRuntimeInstructions without pullRequestLinking, so the <pull_request_linking> block telling the agent to call link_pull_request, watch_pull_request and unwatch_pull_request went into the session instructions on every turn even though those tools did not exist. The fix passes pullRequestLinking: mcpAvailable, the same flag the orchestration guidance uses. The ACP adapter passes this option the same way. One call site changed, no new parser or regex. The two tests on factory/repro-35588 (external server, and MCP add failed) fail without the fix and pass with it. The bug was reproduced with those tests, not against a live external OpenCode server.
Fixes #35588
Reproduction on main
Commit 932cbd4 (origin/main). Started OpenCode 2.2.7 (
@opencode/cli) as an independent server:opencode serve --hostname 127.0.0.1 --port 49374with isolated XDG config/data dirs. Started T3 withT3CODE_DEV_SEED=0 vp run devand paired the preview browser. In Settings > Providers > Add provider I added an OpenCode instance and set Binary path, Server URL http://127.0.0.1:49374 and the server password. In a new thread I chose Claude Haiku 5.5 on that provider and sent one message asking the agent to list its tools whose names contain pull_request. The turn completed. On the OpenCode server,GET /api/mcp?location[directory]=<thread dir>returneddata: [], so no T3 MCP was registered.GET /api/experimental/session/<id>/instructions/entriesreturned keyt3-code, containing <runtime_info> and the full <pull_request_linking> block (link_pull_request, watch_pull_request, unwatch_pull_request, 'no sleep, loops ... for PR waits') and no orchestration guidance. The agent replied: "I don't have any tools with "pull_request" in their name, so the list is empty." On branch factory/repro-35588 (5a23f69), two tests in OpenCode2AdapterV2.test.ts fail on main with an instructions-frame mismatch: the external-server case and the existing MCP-add-failed case. PassingpullRequestLinking: mcpAvailablemakes all 158 tests in the file pass; that fix is not on the branch.Evidence
Evidence: configure an external OpenCode 2.2.7 provider on each fresh T3 server, run the same tool-list request, then inspect the completed conversation and OpenCode's session instructions. Both sessions have an empty MCP list. Base includes mandatory PR-tool instructions; head omits them while retaining runtime information.
Transcript images render actual endpoint output, with runtime attribution redacted. Web captures use the same viewport, theme and crop. Before transcript · After transcript · Reproduction driver · Instruction capture script
AI-assisted; verified with the tests and tools listed above. No tests were used as proof.
Not shown:
Tests
vp test run src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts (apps/server): without the fix, 2 failed and 156 passed (the two repro tests); with the fix, 158 passed. vp run check:changed: format, lint, knip, graphql, typecheck (10 packages) and tests (2 files, 160 tests) all passed.
AI-assisted; verified with the tests and tools listed above.