Repository navigation
fix(opencode): define the v2 explore subagent inline and stop advertising phantom agents - #1188
Merged
catatafishen merged 1 commit intoOct 17, 2026
Conversation
…sing phantom agents The advertised Explore subagent cannot work on OpenCode v2: the bundled prompt was written for v1's deploy-to-directory mechanism and never reaches a v2-readable location, and v2's built-in explore is toolless in this plugin's sessions (no execute permission, native tools denied by the plugin's own config). The client now injects the IDE explore definition inline via OPENCODE_CONFIG_CONTENT when the probed version is v2+: mode subagent (inherits the session model), a Ruleset permissions array (execute allowed first, the 18 read-only agentbridge_* tools allowed, the 7 mutating ones plus edit/write/patch/bash/shell denied), and the bundled prompt as system with the v1 frontmatter stripped. Config-agent rules merge after the built-in policy, last-match-wins (verified via opencode debug agents on v2.0.27); v1 and unknown versions keep the existing config. The Agent menu's built-in list is also v1-era: on v2 only build and plan are primary modes (general and explore are Task-tool subagents, scout does not exist), so those three are dropped on v2+. Custom agents are now also picked up from both user-level global directories (~/.opencode/agents and ~/.config/opencode/agents, the former winning on slug collisions; project agents override globals, built-ins are never shadowed).
BambinoSK
requested a deployment
to
fuzzing-gate
October 16, 2026 21:18 — with
GitHub Actions
Waiting
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
catatafishen
approved these changes
Oct 17, 2026
This branch is waiting to be deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1187.
Problem
On OpenCode v2 the connector advertises an Explore subagent that cannot work, and the Agent menu lists agents that do not exist. See #1187 for the full analysis: the IDE-integrated explore prompt never reaches a v2-readable location (it was written for v1's deploy-to-directory mechanism), and v2's built-in explore is toolless in this plugin's sessions because the plugin's own config denies the native tools while the built-in has no
executepermission (the only reachability path for MCP tools in v2 Code Mode). The menu's built-in list is a v1-era snapshot (generalandexploreare Task-tool subagents on v2,scoutdoes not exist), and user-level custom agents from the global agent directories never appear in the dropdown even though the agent advertises them as selectable modes.What this PR does
OPENCODE_CONFIG_CONTENT) gains anagents.exploreentry:mode: subagent, no model key (inherits the session model), the bundled prompt as a plainsystemstring with its v1 frontmatter stripped, and permissions as a v2 Ruleset array:executeallowed first, the 18 read-onlyagentbridge_*MCP tools allowed, the 7 mutating ones denied,edit/write/patch/bash/shelldenied. Config-agent rules merge after the built-in policy, last-match-wins, so the injected rules win for every action they cover and the built-in catch-all deny blocks uncovered MCP actions. The version probe result is cached and reused when building the config, so v1 and unknown versions keep the existing behavior.buildandplan(the primary session modes);general,explore, andscoutare dropped from the menu. The explore subagent stays available to the model through the injected config. v1 and unknown versions keep the full list.~/.opencode/agentsand~/.config/opencode/agents, with OpenCode's own precedence:~/.opencodewins over the XDG dir on slug collisions, a project agent wins over a same-slug global one, and built-ins are never shadowed (enforced in the merge itself). This also fixes the near-duplicateModeand session-option sections that leaked into the menu whenever a global custom agent made the agent list and the advertised mode values diverge.Notes for reviewers
agentsentries (description,mode,permissions,system;additionalProperties: false), and the ruleset is the documented ordered array of{action, resource, effect}.write/patch/bashdenies duplicateedit/shellcoverage under v2 action naming; they are kept as defense in depth and are normalized by the runtime.write/patch/bashdenies and the top-level v1-stylepermissionmap are accepted and normalized by v2.0.27 even though current docs preferedit/shelland a top-levelpermissionsarray; the top-level map is pre-existing behavior left unchanged here.---inside the prompt body survives); an unclosed fence is treated as malformed and skips the injection rather than leaking YAML into the prompt.Verification
:plugin-core:testbatches run green on the squashed commit:OpenCodeInlineAgentConfigTest(8/8, including an exact 31-rule pin and a loop over all 7 mutating denies),OpenCodeClientStaticMethodsTest(30/30),ProjectAgentScannerDirectoryScanTest(4/4),OpenCodeClientBehaviorTest(11/11), plusOpenCodeVersionProbeTestandProjectAgentScannerTest.opencode debug agents) and the merged permission chain inspected: agent rules appended last,executeallowed, mutating tools denied, uncovered actions blocked by the built-in catch-all deny.How to verify the interactive behavior
<name>.mdagent to~/.config/opencode/agentsand reopen the menu. Expected: it appears in the Agent section.Closes #1187