google-gemini/gemini-cli · error · Error

Failed to initialize RemoteAgentInvocation for '${definition

Error message

Failed to initialize RemoteAgentInvocation for '${definition.name}': A2AClientManager is not available.

What it means

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.

Source

Thrown at packages/core/src/agents/remote-invocation.ts:81

    _toolName?: string,
    _toolDisplayName?: string,
  ) {
    const query = params['query'] ?? DEFAULT_QUERY_STRING;
    if (typeof query !== 'string') {
      throw new Error(
        `Remote agent '${definition.name}' requires a string 'query' input.`,
      );
    }
    // Safe to pass strict object to super
    super(
      { query },
      messageBus,
      _toolName ?? definition.name,
      _toolDisplayName ?? definition.displayName,
    );
    const clientManager = this.context.config.getA2AClientManager();
    if (!clientManager) {
      throw new Error(
        `Failed to initialize RemoteAgentInvocation for '${definition.name}': A2AClientManager is not available.`,
      );
    }
    this.clientManager = clientManager;
  }

  getDescription(): string {
    return `Calling remote agent ${this.definition.displayName ?? this.definition.name}`;
  }

  private async getAuthHandler(): Promise<AuthenticationHandler | undefined> {
    if (this.authHandler) {
      return this.authHandler;
    }

    if (this.definition.auth) {
      const targetUrl = getRemoteAgentTargetUrl(this.definition);
      const provider = await A2AAuthProviderFactory.create({

View on GitHub (pinned to 5024443c72)

Solutions

  1. Ensure the Config used to build AgentLoopContext has A2A enabled and getA2AClientManager() returns a manager.
  2. Register remote agents only when the A2A client manager is present (guard at registration, mirroring registry.ts which skips registration when it is absent).
  3. Avoid constructing RemoteAgentInvocation in tests without injecting a stub client manager.

Example fix

// before: registration not guarded
registerRemoteAgent(def);

// after: only register when the manager exists
if (config.getA2AClientManager()) registerRemoteAgent(def);
Defensive patterns

Strategy: validation

Validate before calling

function assertA2A(config) {
  if (!config.getA2AClientManager())
    throw new Error('A2AClientManager not available; enable A2A in config');
}

Type guard

function hasA2AManager(config) {
  return !!config.getA2AClientManager();
}

Prevention

When it happens

Trigger: Instantiating RemoteAgentInvocation in a context where the Config did not provision an A2AClientManager (the A2A subsystem is disabled or unavailable).

Common situations: 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.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/62acd8bdffeb3e38. Report an issue: GitHub.