Skip to content

Run the ACP bb-bridge MCP server from the bridge module, not the bootstrap - #1932

Merged
SawyerHood merged 1 commit into
mainfrom
bb/fix-1918-thr_i5t6mxi976
Aug 19, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/fix-1918-thr_i5t6mxi976

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

What was wrong

Since #1640 the agent runtime starts every provider bridge through the provider-bridge bootstrap (node <bridge-worker-entry> <bridge module> <pluginId> <dataDir>), so inside the ACP bridge process.argv[1] is the bootstrap, not the bridge module. resolveBridgeProcessArgsForMcpServer() in plugins/provider-acp/src/bridge/bridge.ts still used process.argv[1] as the entry for the bb-bridge MCP server child. The child ran the bootstrap with --mcp-stdio, printed provider bridge bootstrap usage: ... and exited 1. ACP agents (omp, Cursor, Grok, Pi ACP) then rejected session/new with bb-bridge: Transport closed, and bb showed only Internal error because agent-connection.ts dropped error.data. Root-cause report: https://get-bb.github.io/reports/issues/1918.html

What changed

  • plugins/provider-acp/src/bridge/bridge.ts: the MCP server entry is now fileURLToPath(import.meta.url) (the bridge's own module/artifact in every launch mode), with process.execArgv and --mcp-stdio as before.
  • plugins/provider-acp/src/bridge/agent-connection.ts: new formatAgentError() appends error.data.details (or a string / JSON data) to the rejected Error, so agent-side failures such as Internal error: bb-bridge: Transport closed are diagnosable from bb logs.
  • New test src/bridge/mcp-server-entry.test.ts: spawns the bridge under the real bootstrap, reads the advertised bb-bridge MCP server config from the fake ACP agent, and executes that command; it must answer MCP initialize. Existing tests only hit the TCP side channel and import the bridge in-process (argv[1] is vitest there), so they did not catch this.
  • New test src/bridge/agent-connection.test.ts for formatAgentError().

No wire change between server and host daemon, so no HOST_DAEMON_PROTOCOL_VERSION bump.

How you verified

mcp-server-entry.test.ts fails on main (a76bab0):


 ❯  bb-plugin-provider-acp  src/bridge/mcp-server-entry.test.ts (1 test | 1 failed) 418ms
     × advertises an MCP server command that answers MCP initialize when the bridge runs under the bootstrap 417ms

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL   bb-plugin-provider-acp  src/bridge/mcp-server-entry.test.ts > bb-bridge MCP server entry point (#1918) > advertises an MCP server command that answers MCP initialize when the bridge runs under the bootstrap
AssertionError: expected 'provider bridge bootstrap usage: <bri…' not to match /provider bridge bootstrap usage/u

- Expected:
/provider bridge bootstrap usage/u

+ Received:
"provider bridge bootstrap usage: <bridgeModulePath> <pluginId> <pluginDataDir> (absolute paths)
"

 ❯ src/bridge/mcp-server-entry.test.ts:272:24
    270|
    271|     const { exitCode, stderr, stdoutLines } = await runMcpInitialize(c…
    272|     expect(stderr).not.toMatch(/provider bridge bootstrap usage/u);

After the fix:


 Test Files  2 passed (2)
      Tests  4 passed (4)
   Start at  15:58:07
   Duration  3.09s (transform 876ms, setup 0ms, import 1.38s, tests 1.55s, environment 0ms)

pnpm exec turbo run test typecheck --filter=bb-plugin-provider-acp --force:

bb-plugin-provider-acp:test:  Test Files  11 passed (11)
bb-plugin-provider-acp:test:       Tests  165 passed (165)
 Tasks:    3 successful, 3 total

Live check on a dev instance from this branch (scripts/bb-dev-app current) with acp-grok: bb thread spawn --provider acp-grok reaches idle (before the fix this failed at thread start with Internal error), and the agent reports FOUND bb-bridge/update_environment_directory with the tool description when asked to search its MCP tools.

Fixes #1918

AGENT GENERATED: by Claude Opus 5

…strap

Since #1640 the provider bridge runs under the provider-bridge worker
bootstrap, so process.argv[1] inside the bridge names the bootstrap. The
ACP bridge used argv[1] as the entry for the bb-bridge MCP server child,
which exited with the bootstrap usage error and made ACP agents reject
session/new with 'bb-bridge: Transport closed' (shown as 'Internal error').

Use the bridge's own import.meta.url as the MCP server entry, carry
error.data.details into rejected agent errors, and add a test that runs
the bridge under the bootstrap and executes the advertised MCP command.

Fixes #1918

Co-Authored-By: Claude <[email protected]>
@bb-slop-cop

bb-slop-cop Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I am SlopCop. I am reviewing this change for security, code quality, performance, architecture, and test coverage.

I will post one final review after the parallel checks finish.

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Plain-English summary

This change fixes how BB starts its tool server for ACP agents. BB now runs the bridge module instead of the worker bootstrap. ACP sessions no longer fail because the tool transport closes during setup. The change also adds useful agent error details and a process-level regression test.

Review result

I found no blocking defects. I found no concrete security, correctness, performance, architecture, or duplicate-code defect.

  • Security: The change adds no new trust boundary. The ACP child already controlled the existing error message path.
  • Quality: import.meta.url selects bridge.ts in source and built host.js in a package.
  • Architecture: The repository has no duplicate production resolver for this MCP entry. A daemon protocol increase is not necessary.
  • Performance: The new error formatting runs only after an agent error. The repaired process path adds no hot-path cost.
  • Refactor check: The new test repeats small process-test helpers. A shared helper has little value for one test.

Validation

  • All 165 ACP package tests passed through Turbo.
  • The ACP package type check passed through Turbo.
  • git diff --check passed.
  • All GitHub checks passed.
  • The built host.js returned a valid MCP initialize response.
  • The current dev app loaded through Dev Browser.
  • A real OpenCode ACP thread completed and returned ok. This test used the repaired provider bridge path.

The repository has no browser route for the MCP transport itself. The process test and live ACP thread give direct coverage.

As optional hardening, a later change can limit ACP error text and use a bounded MCP input reader. Those concerns predate this repair and do not block it.

@SawyerHood
SawyerHood merged commit aab0cd7 into main Aug 19, 2026
12 checks passed
@SawyerHood
SawyerHood deleted the bb/fix-1918-thr_i5t6mxi976 branch August 19, 2026 16:41
ymichael added a commit that referenced this pull request Aug 19, 2026
The test landed on main reading item/agentMessage/delta from the deleted
thread/event notifications; the bridge behavior it verifies (the MCP
server command advertised from the bridge module under the bootstrap)
already worked — only the test's assistant-text observer was stale.

Co-Authored-By: Claude Fable 5 <[email protected]>
ymichael added a commit that referenced this pull request Aug 19, 2026
The test landed on main reading item/agentMessage/delta from the deleted
thread/event notifications; the bridge behavior it verifies (the MCP
server command advertised from the bridge module under the bootstrap)
already worked — only the test's assistant-text observer was stale.

Co-Authored-By: Claude Fable 5 <[email protected]>
ymichael added a commit that referenced this pull request Aug 19, 2026
The test landed on main reading item/agentMessage/delta from the deleted
thread/event notifications; the bridge behavior it verifies (the MCP
server command advertised from the bridge module under the bootstrap)
already worked — only the test's assistant-text observer was stale.

Co-Authored-By: Claude Fable 5 <[email protected]>
ymichael added a commit that referenced this pull request Aug 20, 2026
## What was wrong

Cursor ACP applies its project MCP approval gate to client-supplied
session MCP servers. ACP has no client permission round trip for that
gate, so Cursor rejected the valid `bb-bridge` stdio config before
spawning it. The same config-advertisement path exists before and after
#1834, and the #1932 bootstrap fix remains valid; the missing Cursor
approval was the separate root cause.

## What changed

The ACP bridge now installs the exact bb-owned session MCP fingerprint
in the Cursor project approval store before `session/new`,
`session/load`, or `session/fork`. It limits the workaround to
`cursor-agent` plus the `bb-bridge` config, preserves existing
approvals, serializes concurrent updates, and removes approvals that bb
installed when the session ends.

The MCP child also reports `initialize` back to the bridge, giving
host-side diagnostics for both config construction and successful child
startup. No server/host-daemon wire contract changed, so
`HOST_DAEMON_PROTOCOL_VERSION` does not need a bump.

## How you verified

Added fingerprint, approval-file preservation/concurrency,
session-lifecycle, and MCP initialize diagnostic regressions. These
expose the missing approval before the fix and pass afterward.

- `pnpm exec turbo run test --filter=bb-plugin-provider-acp --force` —
175 passed
- `pnpm exec turbo run typecheck --filter=bb-plugin-provider-acp`
- Isolated manual run against Cursor CLI `2026.06.19-20-24-33-653a7fb`,
with approval installed after ACP `initialize` and before `session/new`;
Cursor spawned and initialized the MCP server

Fixes #2018

> AGENT GENERATED: by GPT-5
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.

internal error when use omp Agent

1 participant