Skip to content

List OpenCode's project agents in the ACP provider's mode menu - #5455

Merged
SawyerHood merged 2 commits into
mainfrom
acp-custom-agents
Oct 14, 2026
Merged

SawyerHood merged 2 commits into
mainfrom
acp-custom-agents

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

A user reported that the new ACP provider (bb--provider-acp-next) lists only OpenCode's built-in agents (Build, Plan) in the new-thread "Session Mode" menu, while other ACP clients also list their custom agents.

OpenCode reports its primary agents as the ACP mode config option and resolves them from the session's working directory: the global agents plus the project's own .opencode/agent/*.md. bb read an ACP agent's models and options once per machine (models.scope: "host"), and the bridge opened its discovery session in its own process directory. A project's agents therefore never appeared before a thread existed.

What changed

  • Bridge (packages/provider-bridge-acp-next): model/list runs discovery in the cwd the server names. A launch spec that sets its own cwd still wins, and a path that is not a directory falls back to the previous behaviour.
  • Plugin (plugins/provider-acp-next): agents carry a modelCatalogScope. The built-in OpenCode agent and custom agents with "dialect": "opencode" declare workspace; every other ACP agent stays host. I kept the others machine-wide because a workspace-scoped catalog makes a thread page's model button read "Loading models" for about two seconds the first time it opens. OpenCode threads now have that delay, as Pi threads already do.
  • Server: GET /api/v1/system/execution-options accepts projectId (rejected together with environmentId). The server resolves the project's checkout on the target machine and reads a workspace-scoped catalog there. projectCheckoutPathOnHost moved from thread creation into services/projects/project-workspace.ts so both callers share it.
  • SDK and CLI: sdk.providers.models({ projectId }) and bb provider models --project <id>.
  • App: the new-thread composer sends the selected project for providers whose catalog is workspace-scoped. The query key and the last-known catalog cache are keyed by project; a project's first read shows the machine-level catalog as a placeholder until its own arrives.
  • Discovery sessions are deleted: every discovery session/new used to leave an empty "New session" row in OpenCode's history, and per-project discovery would have multiplied them. The bridge now sends ACP session/delete when the agent advertises it, and otherwise, for the opencode dialect, runs opencode session delete <id> after the agent exits.
  • Docs: providers guide, the bb-cli skill reference, the ACP plugin overview and skill, and docs/provider-plugin-api.md. The guide and the ACP skill also say that OpenCode does not read agent files from other folders such as .agents/agents/, and how OPENCODE_CONFIG_DIR makes a per-project folder appear in the mode menu.

No HOST_DAEMON_PROTOCOL_VERSION bump: the server already sends cwd on model/list for workspace-scoped providers, and no daemon contract file changed. The plugin SDK surface is unchanged.

How you verified

Tests added:

  • Bridge: discovery runs in the workspace bb names; the discovery session is deleted over ACP when the agent supports it; it is deleted through OpenCode's CLI when it does not.
  • Plugin: OpenCode agents declare a workspace-scoped catalog and other agents a machine-wide one.
  • Server: a workspace-scoped catalog is read in the project's checkout on the machine; a project on another machine, a host-scoped provider and a missing project are covered.
  • Contract, SDK, CLI and app: projectId validation and forwarding, the --project flag, when the composer names the project, and the per-project cache with its placeholder.

Commands, on this commit rebased onto current main:

  • turbo run typecheck lint --filter='...[origin/main]': 121 tasks pass.
  • turbo run test for the nine touched packages.
  • node .github/workflows/check-plugin-sdk-version.mjs and node packages/plugin-sdk/scripts/check-npm-version-guard.mjs.

Manual, in the dev app on Linux with OpenCode 1.18.35 and a project that has two .opencode/agent files:

  • With no project selected the mode menu lists build, docs and plan. With the project selected (Project checkout or Worktree) it also lists the two project agents.
  • A new Worktree thread started on a project agent answered as that agent. bb thread spawn --option mode=<agent> --new-environment worktree did the same from the CLI.
  • A cold discovery for a fresh project left no sessions in OpenCode's session list.
  • Agents kept in .agents/agents/: OpenCode 1.18.35, 1.19.0 and the OpenCode 2 beta do not list them from the project, a parent folder or the home directory. With OPENCODE_CONFIG_DIR=.agents, set as a machine variable for the built-in agent or in a custom agent's env, the mode menu listed the project's .agents/agents agent and a new Worktree thread answered as that agent. A changed machine variable reached the mode list about a minute and a half later, or at once after a plugin reload.
  • The OpenCode 2 beta (opencode2 acp), added as a custom agent with "dialect": "opencode", listed the project agents, ran a thread on one, and had its discovery session removed over ACP session/delete.

Not tested: a remote machine, macOS, Windows, and an OpenCode 1 release newer than 1.18.35.

🤖 Generated with Claude Code

AGENT GENERATED

OpenCode reports its primary agents as the ACP "mode" option and resolves
them from the session's working directory: the global agents plus the
project's own `.opencode/agent` files. bb read an ACP agent's options once
per machine, in the bridge's own process directory, so a new thread's mode
menu listed only the built-in agents and any global ones.

- The ACP bridge runs `model/list` discovery in the workspace bb names.
- OpenCode (the built-in agent and custom agents with the opencode dialect)
  declares a workspace-scoped model catalog; every other ACP agent keeps
  the machine-wide one.
- `GET /system/execution-options` accepts `projectId` so a new thread can
  name its project before an environment exists. The SDK and
  `bb provider models --project <id>` carry it, and the new-thread composer
  sends it for providers with a workspace-scoped catalog.
- The bridge deletes the session it opens to read an agent's options, over
  ACP `session/delete` when the agent advertises it and through
  `opencode session delete` otherwise, so discovery no longer leaves empty
  sessions in OpenCode's history.

Co-Authored-By: Claude Code <[email protected]>
@SawyerHood
SawyerHood marked this pull request as ready for review October 13, 2026 23:49
OpenCode lists only the agents it loads itself and does not read
`.agents/agents/`. Say so in the providers guide and the ACP skill, with the
`OPENCODE_CONFIG_DIR` setting that makes a per-project folder appear in the
mode menu.

Co-Authored-By: Claude Code <[email protected]>
@SawyerHood
SawyerHood merged commit daf1438 into main Oct 14, 2026
48 checks passed
@SawyerHood
SawyerHood deleted the acp-custom-agents branch October 14, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant