vercel/ai · error

ACP session initialization did not produce a session.

Error message

ACP session initialization did not produce a session.

What it means

After ACP session initialization completes inside runTurn, the bridge asserts that the session variable was actually assigned; if it is still null/undefined, this Error is thrown because a turn cannot proceed without an ACP session id. Normally the initialize handshake produces a session; hitting this means the handshake silently completed without one, indicating a bug or an unexpected agent response shape.

Source

Thrown at packages/harness-acp/src/v1/bridge/index.ts:152

});

async function runTurn(start: StartMessage, turn: BridgeTurn): Promise<void> {
  let initialHostToolCatalogRefreshRequired: boolean;
  try {
    ({ initialHostToolCatalogRefreshRequired } = await ensureSession({
      start,
      turn,
    }));
  } catch (error) {
    if (HarnessBridgeCapabilityUnsupportedError.isInstance(error)) throw error;
    throw createACPBridgeError({
      stage: 'session initialization',
      cause: error,
    });
  }
  const activeSession = session;
  if (activeSession == null) {
    throw new Error('ACP session initialization did not produce a session.');
  }
  const activeAgentResponseStreamFailure = agentResponseStreamFailure;
  if (activeAgentResponseStreamFailure == null) {
    throw new Error(
      'ACP session initialization did not start stderr monitoring.',
    );
  }
  const activeHostToolRelay = hostToolRelay;
  if (activeHostToolRelay == null) {
    throw new Error('The host tool MCP relay is unavailable.');
  }
  if (start.recoveryMode?.type === 'lossy-rerun') {
    const marker = {
      type: 'acp-recovery',
      mode: 'lossy-rerun',
      reason: start.recoveryMode.reason,
    } as const;
    turn.emit({ type: 'raw', rawValue: marker });

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Inspect the agent's response to session initialization and confirm it returns a valid sessionId.
  2. Update or fix the ACP agent binary/adapter so it conforms to the ACP session/new response schema.
  3. Capture the agent's stderr/stdout during startup to see whether the agent crashed or mis-responded during initialization.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await bridge.runTurn({ prompt });
} catch (error) {
  if (error instanceof Error && error.message.includes('did not produce a session')) {
    // inspect agent initialization response / restart the agent
  }
  throw error;
}

Prevention

When it happens

Trigger: The ACP agent's initialize/newSession handshake resolves (or the wrapped failure path is entered) without the session variable being populated before runTurn continues to execute the turn.

Common situations: A buggy or non-conformant ACP agent binary that replies to session/new without a sessionId; an agent that exits immediately so initialization resolves abnormally; wrapping a custom agent that implements the ACP protocol incorrectly.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/1f2f5e1edeb6824f. Report an issue: GitHub.