Skip to content

Commit 1a42091

Browse files
only21milclaude
andcommitted
perf(provider-acp): run MCP-over-ACP calls concurrently after the handshake
One lock covered each whole POST and response read, so a short call on a connection waited for any long call, such as t3_thread_wait, to finish. Keep the lock only until initialize negotiates a protocol version. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7921ee7 commit 1a42091

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎packages/provider-acp/src/server/mcpOverAcpBridge.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,20 @@ export const makeAcpMcpOverAcpBridge = Effect.fn("AcpMcpOverAcpBridge.make")(fun
9292
: Effect.succeed(connection);
9393
});
9494

95+
// Messages wait for the initialize handshake, then run concurrently so a short
96+
// call does not queue behind a long one such as t3_thread_wait.
97+
const untilNegotiated =
98+
(connection: Connection) =>
99+
<A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> =>
100+
Effect.suspend(() =>
101+
connection.protocolVersion === null ? connection.mutex.withPermits(1)(effect) : effect,
102+
);
103+
95104
const send = (
96105
connection: Connection,
97106
message: unknown,
98107
): Effect.Effect<ReadonlyArray<unknown>, AcpMcpOverAcpError> =>
99-
connection.mutex.withPermits(1)(
108+
untilNegotiated(connection)(
100109
Effect.gen(function* () {
101110
const body = JSON.stringify(message);
102111
if (Buffer.byteLength(body) > MAX_MESSAGE_BYTES) {

0 commit comments

Comments
 (0)