Skip to content

Translate BB skill chips before ACP prompts - #5055

Closed
timurkhakhalev wants to merge 1 commit into
get-bb:mainfrom
timurkhakhalev:codex/fix-acp-skill-invocation
Closed

timurkhakhalev wants to merge 1 commit into
get-bb:mainfrom
timurkhakhalev:codex/fix-acp-skill-invocation

Conversation

@timurkhakhalev

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

BB skill chips reached ACP agents as literal /skill-name text while their skill metadata was discarded. OpenCode interpreted a leading chip as its own slash command; a bb-only name completed an empty turn without model inference. See #4923.

What changed

  • Keep the names from the session's injected BB skill catalog.
  • Translate validated slash skill mentions from that catalog to Use the bb skill "name" before building ACP prompt text. The existing catalog still points the agent to the skill's SKILL.md.
  • Preserve surrounding text and native provider commands, native-only skills, and unmarked slash text. Process multiple mentions from right to left and reject mismatched or overlapping ranges.
  • Add eight transport regression/control cases covering skill-only and argument-bearing prompts, UTF-16 offsets, multiple/duplicate mentions, and command/plain-text controls.

No protocol fields, CLI options, dependencies, or installed application artifacts change. This is independent of the model-selection PR #5053.

How you verified

  • pnpm exec turbo run typecheck test lint --filter=@bb/provider-bridge-acp: passed; 382 tests passed, 4 skipped, 19 files.
  • On original main bridge code, the four skill-translation regression cases fail while the four preservation controls pass; all eight pass with the fix.
  • Real OpenCode 1.18.34 in a temporary HOME/XDG/workspace, with only a localhost OpenAI-compatible fake backend and synthetic credentials:
    • Raw /example-skill …: end_turn, zero inference requests, zero assistant message chunks.
    • Known provider /fixture-command: reaches the local backend and completes.
    • After a warm-up turn, the same BB skill chip through the bundled fixed bridge reaches the backend as Use the bb skill … and produces an assistant response: one inference request.
  • Reviewed the focused diff; formatting and git diff --check pass. No paid inference, original chat contents, real credentials, or private entity IDs were used or published.

Fixes #4923

AGENT GENERATED

SawyerHood added a commit that referenced this pull request Oct 20, 2026
## Human comments

## What was wrong

bb shipped two ACP adapters side by side: the original
(`packages/provider-bridge-acp`, plugin `provider-acp`, on by default)
and the rebuilt one from #5266 (`packages/provider-bridge-acp-next`,
plugin `bb--provider-acp-next`, opt-in and mutually exclusive through
`BUNDLED_PLUGIN_REPLACEMENTS`). Fixes had to be made twice, and some
weren't: #5374's shutdown cleanup only reached the original bridge.
Deleting the original plugin directly would have caused data loss. The
orphaned-builtin cleanup (`removeUnbundledBuiltins`) deletes a removed
built-in's settings, so every default user's `customAgents` would have
been wiped. Users who had opted in would have been left with
`provider-acp` disabled and no ACP providers.

## What changed

- **In-place swap.** The rebuilt bridge and plugin now live at
`packages/provider-bridge-acp` and `plugins/provider-acp`, under the
original package names and the `provider-acp` plugin id. Default users'
plugin rows, `customAgents`, and threads carry over unchanged, since
provider ids are the same (`acp-cursor`, …). The `-next` directories are
deleted. So are the opt-in switch (`BUNDLED_PLUGIN_REPLACEMENTS`, the
`standsAside` catalog filter and the paired enable/disable in
`setEnabled`) and their tests. Hardcoded `bb--provider-acp-next` ids in
the plugin (`known-agents.ts`, `registry-icons.ts`, `usage-source.ts`)
are now `provider-acp`. Registry icon refs resolve as
`provider-acp/registry-*`.
- **Handover for opted-in users.** `RETIRED_BUNDLED_PLUGINS` in
`builtin-registry.ts` declares `bb--provider-acp-next` → `provider-acp`.
At startup, `handOverRetiredBuiltins()` runs before
`removeUnbundledBuiltins()`. If the retired row was enabled, it copies
`customAgents` to `provider-acp` and turns `provider-acp` on. Then it
deletes the retired row's settings, secrets and schedules. It does not
clear the user's disabled-provider list, which normal orphan cleanup
would, because both plugins own the same provider ids.
- **Plugin SDK.** `@get-bb/plugin-sdk/provider-bridge/acp` now exports
the rebuilt bridge. The export names and type shapes are the same as
before, plus `experimental_registerAcpDialect`.
`provider-bridge/acp-next` stays as a deprecated alias re-exporting
`/acp`. `docs/api_to_audit.md` merges the two entries. No wire change;
`HostDaemonAcpLaunchSpec` is identical.
- **#5374 ported to the rebuilt bridge.** Every agent connection (thread
sessions, model discovery, session-option discovery) is tracked and
removed on exit. New connections are refused once shutdown starts. stdin
close, SIGTERM and SIGINT share one awaited cleanup that releases
sessions and kills tracked agents. Includes `shutdown.test.ts` from
#5374.
- **References.** Updated `bundled-plugins`, `bb-official.json`,
`first-party-plugins.json`, `forkable-plugins.json`, the web
bundled-marketplace list, `turbo.json` (the -next task config moved to
`bb-plugin-provider-acp`), the provider-literal ratchet, plugin-build
tests, `docs/configuration.md`, and the bb-guide plugin-authoring
references.

## How you verified

- `pnpm exec turbo run typecheck lint` for `@bb/provider-bridge-acp`,
`bb-plugin-provider-acp`, `@get-bb/plugin-sdk`, `@bb/server`, `@bb/web`,
`@bb/domain`, and `@bb/plugin-build`. All passed.
- `turbo run test` passed for the bridge (505 tests, including the 6
ported shutdown cases), the SDK (376), plugin-build (211) and domain
(248).
- The plugin package had 81 of 82 passing. The one failure is
`native-roots.test.ts` omp, an environment-only failure because
`/tmp/.agents` exists on the machine (per `.bb/skills/test-audit`). It
passes with `TMPDIR=/var/tmp/...`.
- Server: `vitest run` over `test/services/plugins`,
`test/services/plugin-catalog`, `test/system/provider-management`,
`test/system/execution-options`,
`test/public/public-provider-installations` and
`test/providers/provider-registry`: 65 files and 765 tests passed. That
includes the new `retired-bundled-plugins.test.ts`, which covers three
cases: an enabled retired plugin hands off settings and turns its
successor on; a disabled one leaves the successor alone and keeps
disabled providers; and a missing successor.
- `packages/agent-runtime` `runtime.acp-topology.test.ts` passed.
- `node scripts/check-plugin-forks.mjs plugins/provider-acp` passed
(with a clean TMPDIR). The provider-literal ratchet passed. The plugin
SDK npm version guard passed (0.6.56 is unpublished, so no bump).
- Not run locally: the full server suite, tarball smoke, Windows, and a
live Cursor/opencode thread on the merged build.

Follow-up: #5692 and #5055 target only the removed original bridge and
need re-targeting; #5694 touches both.

> AGENT GENERATED

---------

Co-authored-by: Sawyer <[email protected]>
@SawyerHood

Copy link
Copy Markdown
Collaborator

Thanks @timurkhakhalev, and sorry this sat so long. #5775 replaced the ACP bridge this PR patched with the rebuilt one, so the change no longer applies as-is. We rebuilt your approach on the new bridge in #5815: every slash chip whose name is a configured bb skill becomes Use the bb skill "name", in any position and any text item, right to left, skipping overlapping or mismatched ranges, and leaving the agent's own commands and non-bb chips alone. You're credited as co-author on that commit. Closing this one in favour of #5815.

AGENT GENERATED

@SawyerHood SawyerHood closed this Oct 20, 2026
SawyerHood added a commit that referenced this pull request Oct 20, 2026
…5815)

## Human comments

## What was wrong

A bb skill chip reaches an ACP agent as literal `/name` text. OpenCode
reads a leading `/name` as one of its own commands and ends the turn
without calling the model (#4923).

The rebuilt bridge rewrote a chip only in narrow cases:
- only a chip at the very start of the first text item,
- only once the agent had advertised its commands.

A chip on the first turn, mid-message, in a later text item, or next to
an advertised command still went through raw.

## What changed

`textWithBbSkillCommandsSpelledOut` (`bridge.ts`) replaces
`textWithoutUnknownLeadingSkillCommand`:
- **What it rewrites:** every slash chip whose name is a configured bb
skill (`skills/configure` roots), in every text item.
- **How:** to `Use the bb skill "name"`, with a trailing colon when the
chip leads further text. Chips are processed right to left, skipping
overlapping or mismatched ranges.
- **What it leaves alone:** the agent's own advertised commands, chips
that are not bb skills, and unmarked slash text.

This follows #5055 by @timurkhakhalev (credited as co-author), rebuilt
on the new bridge.

## How you verified

- The rewritten bridge test covers six turns:
  - first-turn chip,
  - two chips mid-message,
  - a non-bb chip next to a bb chip in a second text item,
  - a mismatched range,
  - after the agent advertises commands,
  - an advertised command next to a bb chip.
- Under the previous rule, the first-turn, mid-message and mixed cases
come out raw.
- `pnpm exec turbo run test lint typecheck
--filter=@bb/provider-bridge-acp --filter=@bb/provider-parity`: bridge
522 passed, parity 59 passed.
- Live with opencode 1.18.35: a message with a project skill chip in the
middle ("First, follow /e2e-greet …") got the skill's exact reply.

Fixes #4923. Supersedes #5055.

> AGENT GENERATED

Co-authored-by: Timur Khakhalev <[email protected]>
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.

acp-opencode: a leading /skill-name for a bb-only skill silently completes an empty turn (provider swallows it as an unknown command)

2 participants