vercel/ai · error

ACP session initialization did not start stderr monitoring.

Error message

ACP session initialization did not start stderr monitoring.

What it means

runTurn requires that session initialization started stderr monitoring for the agent process; the agentResponseStreamFailure variable is assigned by that setup and asserted non-null. If it is still null, the bridge assumes stderr monitoring was never wired up and throws this Error, since agent-side failure output would otherwise be lost.

Source

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

  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 });
    turn.bridgeLog({
      level: 'warn',
      subsystem: 'acp.recovery',
      message:

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Verify that the stderr monitoring setup runs during session initialization and assigns agentResponseStreamFailure before runTurn proceeds.
  2. Check for ordering or race issues between session creation and stderr stream attachment and fix the sequencing.
  3. File/debug as a bridge bug if the stock ACP agent triggers it — user configuration cannot normally cause this error.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await bridge.runTurn({ prompt });
} catch (error) {
  if (error instanceof Error && error.message.includes('did not start stderr monitoring')) {
    // treat as bridge/adapter bug; report with agent and bridge versions
  }
  throw error;
}

Prevention

When it happens

Trigger: The post-initialization path in runTurn where the agentResponseStreamFailure sentinel was not set — i.e. the code that begins consuming the agent process's stderr stream never ran or never recorded its failure slot, even though a session was produced.

Common situations: Internal bridge bug where the stderr-monitoring setup was skipped or its assignment raced; an agent adapter that does not expose a stderr stream; regression after refactoring the initialization sequence so monitoring is started after this assertion.

Related errors


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