{"record":{"id":"9a6c188e029f42e2","repo":"vercel/ai","slug":"acp-prompt-update-stream-failed-causemessage","errorCode":null,"errorMessage":"ACP prompt update stream failed: ${causeMessage}","messagePattern":"ACP prompt update stream failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/harness-acp/src/v1/bridge/index.ts","lineNumber":332,"sourceCode":"      turn.abortSignal.addEventListener('abort', () => void cancel(), {\n        once: true,\n      });\n    }\n    for (;;) {\n      let message: acp.ActiveSessionMessage;\n      try {\n        message = await Promise.race([\n          activeSession.nextUpdate(),\n          cancellationFailure,\n          activeAgentResponseStreamFailure,\n        ]);\n      } catch (error) {\n        for (const rawValue of streamCapture?.drainRawValues() ?? []) {\n          emitStreamEvent.raw({ rawValue });\n        }\n        emitStreamEvent.close();\n        if (error === cancellationFailureError) throw error;\n        throw createACPBridgeError({\n          stage: 'prompt update stream',\n          cause: error,\n        });\n      }\n      if (message.kind === 'session_update') {\n        const captured = streamCapture?.takeForUpdate({\n          update: message.update,\n        });\n        for (const rawValue of captured?.precedingRawValues ?? []) {\n          emitStreamEvent.raw({ rawValue });\n        }\n        emitStreamEvent.message({\n          message,\n          rawUpdate: captured?.rawUpdate,\n        });\n        continue;\n      }\n      for (const rawValue of streamCapture?.drainRawValues() ?? []) {","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-acp/src/v1/bridge/index.ts#L314-L350","documentation":"The ACP (Agent Client Protocol) bridge wraps every failure that occurs while the agent's prompt-update events are being streamed back into the Harness runTurn loop. Instead of letting the raw underlying error escape, the bridge rethrows it as a bridge error with stage 'prompt update stream' and the original error attached as `cause`. The `causeMessage` in the message comes from that underlying failure (connection drop, protocol violation, agent crash, etc.), so read the cause to find the real problem.","triggerScenarios":"Any error thrown inside the prompt/update event stream processing in runTurn: the connected ACP agent closes the connection or crashes mid-turn, sends a malformed session_update, a streamCapture consumer throws, or the underlying transport rejects while emitting raw stream values.","commonSituations":"Agent process killed mid-turn (OOM, timeout, Ctrl-C); network disconnect between client and ACP agent; agent emitting an update that violates the ACP protocol; serialization failure in a custom stream handler.","solutions":["Read `error.cause` (or the causeMessage in the message) to identify the actual underlying failure.","Check that the ACP agent process is still alive and the transport (stdio/socket) did not terminate mid-turn.","Enable ACP diagnostics/logging to capture the last session_update received before the failure.","Retry the turn if the failure was a transient transport drop; otherwise fix the agent or protocol payload that caused the crash."],"exampleFix":"// before: only logging the wrapper message\ncatch (e) { console.log(e.message); }\n// after: surface the underlying cause\ncatch (e) {\n  console.error(e.message, e.cause);\n  if (ACPBridgeError.isInstance(e) && e.stage === 'prompt update stream') {\n    retryTurnOrReportAgentCrash(e.cause);\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isACPBridgeError(e: unknown): e is { stage: string; cause: unknown } {\n  return typeof e === 'object' && e !== null && 'stage' in e && 'cause' in e;\n}","tryCatchPattern":"try {\n  await runTurn(...);\n} catch (error) {\n  if (isACPBridgeError(error) && error.stage === 'prompt update stream') {\n    logger.error('ACP prompt stream failed', { cause: error.cause });\n  }\n  throw error;\n}","preventionTips":["Always log error.cause, not just the top-level message.","Monitor agent process health and transport liveness during turns.","Validate agent update payloads against the ACP protocol to fail fast on malformed input."],"tags":["acp","streaming","agent-protocol","error-wrapping"],"backgroundTag":"stream-wrapped-cause-error","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}