{"record":{"id":"62acd8bdffeb3e38","repo":"google-gemini/gemini-cli","slug":"failed-to-initialize-remoteagentinvocation-for","errorCode":null,"errorMessage":"Failed to initialize RemoteAgentInvocation for '${definition.name}': A2AClientManager is not available.","messagePattern":"Failed to initialize RemoteAgentInvocation for '(.+?)': A2AClientManager is not available\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/remote-invocation.ts","lineNumber":81,"sourceCode":"    _toolName?: string,\n    _toolDisplayName?: string,\n  ) {\n    const query = params['query'] ?? DEFAULT_QUERY_STRING;\n    if (typeof query !== 'string') {\n      throw new Error(\n        `Remote agent '${definition.name}' requires a string 'query' input.`,\n      );\n    }\n    // Safe to pass strict object to super\n    super(\n      { query },\n      messageBus,\n      _toolName ?? definition.name,\n      _toolDisplayName ?? definition.displayName,\n    );\n    const clientManager = this.context.config.getA2AClientManager();\n    if (!clientManager) {\n      throw new Error(\n        `Failed to initialize RemoteAgentInvocation for '${definition.name}': A2AClientManager is not available.`,\n      );\n    }\n    this.clientManager = clientManager;\n  }\n\n  getDescription(): string {\n    return `Calling remote agent ${this.definition.displayName ?? this.definition.name}`;\n  }\n\n  private async getAuthHandler(): Promise<AuthenticationHandler | undefined> {\n    if (this.authHandler) {\n      return this.authHandler;\n    }\n\n    if (this.definition.auth) {\n      const targetUrl = getRemoteAgentTargetUrl(this.definition);\n      const provider = await A2AAuthProviderFactory.create({","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/agents/remote-invocation.ts#L63-L99","documentation":"Thrown in the RemoteAgentInvocation constructor when context.config.getA2AClientManager() returns undefined. Without an A2AClientManager the invocation cannot load the agent or stream messages, so construction aborts.","triggerScenarios":"Instantiating RemoteAgentInvocation in a context where the Config did not provision an A2AClientManager (the A2A subsystem is disabled or unavailable).","commonSituations":"Running in an environment/build where A2A support is not enabled; the config object is a minimal/standalone Config without remote-agent features; feature flag for A2A off; the remote agent was registered against one config but the invocation runs against another.","solutions":["Ensure the Config used to build AgentLoopContext has A2A enabled and getA2AClientManager() returns a manager.","Register remote agents only when the A2A client manager is present (guard at registration, mirroring registry.ts which skips registration when it is absent).","Avoid constructing RemoteAgentInvocation in tests without injecting a stub client manager."],"exampleFix":"// before: registration not guarded\nregisterRemoteAgent(def);\n\n// after: only register when the manager exists\nif (config.getA2AClientManager()) registerRemoteAgent(def);","handlingStrategy":"validation","validationCode":"function assertA2A(config) {\n  if (!config.getA2AClientManager())\n    throw new Error('A2AClientManager not available; enable A2A in config');\n}","typeGuard":"function hasA2AManager(config) {\n  return !!config.getA2AClientManager();\n}","tryCatchPattern":null,"preventionTips":["Build the Config with A2A enabled when remote agents are registered.","Guard remote-agent registration on getA2AClientManager() presence.","Inject a stub manager in tests."],"tags":["a2a","agents","config","initialization"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}