{"record":{"id":"63dd9db2b640e030","repo":"google-gemini/gemini-cli","slug":"a2aclientmanager-sendmessagestream-error-agen-63dd9d","errorCode":null,"errorMessage":"[A2AClientManager] sendMessageStream Error [${agentName}]: Unexpected error during sendMessageStream: ${String(error)}","messagePattern":"\\[A2AClientManager\\] sendMessageStream Error \\[(.+?)\\]: Unexpected error during sendMessageStream: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/a2a-client-manager.ts","lineNumber":228,"sourceCode":"        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.\n   * @param name The name of the agent.\n   * @returns The client, or undefined if not found.","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/agents/a2a-client-manager.ts#L210-L246","documentation":"Sibling of error 175 from the same catch block, fired when the thrown value is *not* an `Error` instance (e.g. a string, number, or plain object). The manager stringifies it and wraps with the same prefix so the traceability is preserved even for non-Error throws from the underlying client or transport.","triggerScenarios":"The A2A client (or a custom fetch/transport injected via auth) throws a non-Error value — a string message, a plain object, or a rejected promise with a non-Error payload. This is the fallback branch of `error instanceof Error ? ... : ...`.","commonSituations":"A third-party transport that does `throw 'timeout'` instead of `throw new Error('timeout')`; a fetch shim rejecting with a Response object; an older JS library that throws strings; a serialization layer that strips the Error prototype.","solutions":["Inspect `String(error)` in the message to recover whatever the underlying layer threw.","Wrap any custom transport/fetch in a layer that converts non-Error throws into `new Error(String(e))` before they reach sendMessageStream.","If you control the client, always throw Error instances.","Treat the message text as a diagnostic and route the original cause through logging for triage."],"exampleFix":"// before — custom fetch rejects with a string\nconst fetchImpl = () => Promise.reject('timeout');\n\n// after — wrap to Error\nconst fetchImpl = () =>\n  Promise.reject(new Error('timeout'));","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  for await (const r of manager.sendMessageStream(name, msg)) {}\n} catch (e) {\n  // e.message embeds String(originalError) — log it for triage\n  logger.error({ message: (e as Error).message });\n  // wrap your transport so future throws are Error instances\n}","preventionTips":["Wrap any custom transport/fetch so its rejections are always Error instances.","Log the full message text — non-Error causes lose fidelity otherwise.","Audit third-party A2A clients for non-Error throws during evaluation."],"tags":["a2a","error-handling","streaming","robustness"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}