Skip to content

fix(opencode): sessions without T3 MCP no longer get PR tool instructions - #35657

Open
juliusmarminge wants to merge 3 commits into
mainfrom
factory/issue-35588
Open

juliusmarminge wants to merge 3 commits into
mainfrom
factory/issue-35588

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

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 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.

Before After
932cbd4e44 857fff9696
Before: actual server instruction transcript After: actual server instruction transcript
Before: completed web conversation After: completed web conversation

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:

  • 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.

juliusmarminge and others added 2 commits November 12, 2026 20:22
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>
…ions

AI-assisted; verified with the tests and tools listed above.
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 12, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 857fff9

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.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 42.9 KiB 42.9 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 42.9 KiB 42.9 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 613d1ac · PR result: ab693a8 · Source CI: failure

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: yash-singh1

Merge Risk: Minimal · up to ab693

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed 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 Passed 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

Usage-based review receipt

Note

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.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 857fff9 and ab693a8.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
  • packages/provider-opencode/src/server/v2/adapter.ts

Limit details: You’ve used all 10 included reviews currently available.

@juliusmarminge

Copy link
Copy Markdown
Member Author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenCode external-server threads receive mandatory instructions for unavailable T3 PR tools

1 participant