{"record":{"id":"de2122c41ed0c0c1","repo":"google-gemini/gemini-cli","slug":"a2aclient-gettask-error-agentname-error-me","errorCode":null,"errorMessage":"A2AClient getTask Error [${agentName}]: ${error.message}","messagePattern":"A2AClient getTask Error \\[(.+?)\\]: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/a2a-client-manager.ts","lineNumber":266,"sourceCode":"  getClient(name: string): Client | undefined {\n    return this.clients.get(name);\n  }\n\n  /**\n   * Retrieves a task from an agent.\n   * @param agentName The name of the agent.\n   * @param taskId The ID of the task to retrieve.\n   * @returns The task details.\n   */\n  async getTask(agentName: string, taskId: string): Promise<Task> {\n    const client = this.clients.get(agentName);\n    if (!client) throw new Error(`Agent '${agentName}' not found.`);\n    try {\n      return await client.getTask({ id: taskId });\n    } catch (error: unknown) {\n      const prefix = `A2AClient getTask Error [${agentName}]`;\n      if (error instanceof Error) {\n        throw new Error(`${prefix}: ${error.message}`, { cause: error });\n      }\n      throw new Error(`${prefix}: Unexpected error: ${String(error)}`);\n    }\n  }\n\n  /**\n   * Cancels a task on an agent.\n   * @param agentName The name of the agent.\n   * @param taskId The ID of the task to cancel.\n   * @returns The cancellation response.\n   */\n  async cancelTask(agentName: string, taskId: string): Promise<Task> {\n    const client = this.clients.get(agentName);\n    if (!client) throw new Error(`Agent '${agentName}' not found.`);\n    try {\n      return await client.cancelTask({ id: taskId });\n    } catch (error: unknown) {\n      const prefix = `A2AClient cancelTask Error [${agentName}]`;","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/agents/a2a-client-manager.ts#L248-L284","documentation":"Thrown by `getTask` when the underlying A2A client's `getTask` call raises an `Error`. The manager wraps the original in a new prefixed Error and chains it via `cause`, preserving the agent name and operation context for downstream handlers.","triggerScenarios":"The remote agent returns an error for the task lookup, the task id does not exist on the remote, the network fails, or an AbortSignal/timeout trips inside `client.getTask`. Any `instanceof Error` throw lands here.","commonSituations":"Polling a task id that has expired or was never created on the remote; transient network failure during retrieval; auth expired between message send and task poll; remote agent restarted and lost task state.","solutions":["Read `error.cause.message` for the original remote error text.","Confirm the taskId was returned by a prior `sendMessageStream` call against the same agent.","Retry with backoff for transient failures; if the task is gone, stop polling and surface a 'task unavailable' status.","Verify auth is still valid (re-load the agent) if the cause suggests a 401/403."],"exampleFix":"// before\ntry { await manager.getTask('rev', id); } catch (e) { throw e; }\n\n// after\ntry { await manager.getTask('rev', id); }\ncatch (e) {\n  if (e instanceof Error && /not found/i.test(e.cause?.message ?? '')) {\n    return null; // task expired\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await manager.getTask(name, taskId);\n} catch (e) {\n  const cause = (e as Error).cause;\n  if (cause instanceof Error && /not found|expired/i.test(cause.message)) {\n    return null; // task is gone — stop polling\n  }\n  if (isTransient(cause)) {\n    await backoff();\n    return await manager.getTask(name, taskId);\n  }\n  throw e;\n}","preventionTips":["Read `error.cause` for the real remote reason.","Bound polling with a max-attempts / max-duration so transient errors don't loop forever.","Persist taskId only from results of a successful sendMessageStream so it always exists remotely."],"tags":["a2a","tasks","network","error-handling"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}