{"record":{"id":"281b720e42831833","repo":"google-gemini/gemini-cli","slug":"a2aclientmanager-sendmessagestream-error-agen","errorCode":null,"errorMessage":"[A2AClientManager] sendMessageStream Error [${agentName}]: ${error.message}","messagePattern":"\\[A2AClientManager\\] sendMessageStream Error \\[(.+?)\\]: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/a2a-client-manager.ts","lineNumber":226,"sourceCode":"    const messageParams: MessageSendParams = {\n      message: {\n        kind: 'message',\n        role: 'user',\n        messageId: uuidv4(),\n        parts: [{ kind: 'text', text: message }],\n        contextId: options?.contextId,\n        taskId: options?.taskId,\n      },\n    };\n\n    try {\n      yield* client.sendMessageStream(messageParams, {\n        signal: options?.signal,\n      });\n    } catch (error: unknown) {\n      const prefix = `[A2AClientManager] sendMessageStream Error [${agentName}]`;\n      if (error instanceof Error) {\n        throw new Error(`${prefix}: ${error.message}`, { cause: error });\n      }\n      throw new Error(\n        `${prefix}: Unexpected error during sendMessageStream: ${String(error)}`,\n      );\n    }\n  }\n\n  /**\n   * Retrieves a loaded agent card.\n   * @param name The name of the agent.\n   * @returns The agent card, or undefined if not found.\n   */\n  getAgentCard(name: string): AgentCard | undefined {\n    return this.agentCards.get(name);\n  }\n\n  /**\n   * Retrieves a loaded client.","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/agents/a2a-client-manager.ts#L208-L244","documentation":"Thrown by `sendMessageStream` when the underlying A2A client's stream raises an `Error`. The manager catches it, prefixes it with the agent name and method for traceability, and re-throws a new Error that preserves the original as `cause`. This is the 'known Error shape' branch of the catch.","triggerScenarios":"The remote A2A agent returns an error response over the stream, the network connection drops mid-stream, the client times out, or an AbortSignal fires and the client surfaces it as an Error. Any of these land in the `error instanceof Error` branch.","commonSituations":"Remote agent crashed or returned an error event; transient network failure during streaming; an AbortController aborted the request; auth token expired mid-conversation; the remote agent rejected the message payload.","solutions":["Inspect `error.cause` for the original message from the A2A client — the actionable detail is there.","For transient/network errors, retry with backoff, optionally resuming via `contextId`/`taskId` from the options.","If an AbortSignal was used, check whether it was aborted and either widen the timeout or stop aborting.","For remote error responses, validate the message payload and the agent's health (re-fetch its AgentCard) before retrying."],"exampleFix":"// before\ntry {\n  for await (const r of manager.sendMessageStream('rev', msg)) {}\n} catch (e) {\n  console.error((e as Error).message); // loses cause\n}\n\n// after\ntry {\n  for await (const r of manager.sendMessageStream('rev', msg)) {}\n} catch (e) {\n  console.error((e as Error).message, (e as Error).cause);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  for await (const r of manager.sendMessageStream(name, msg, { signal })) {}\n} catch (e) {\n  const cause = (e as Error).cause;\n  if (cause instanceof Error && isRetryable(cause)) {\n    await backoff();\n    // retry with contextId to resume\n  } else {\n    throw e;\n  }\n}","preventionTips":["Always read `error.cause` for the real A2A failure detail.","Pass an AbortSignal with a sane timeout to surface cancellations as Errors you can retry.","Persist contextId/taskId so a retry can resume the conversation rather than restart."],"tags":["a2a","streaming","network","error-handling"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}