# Class RemoteA2AAgent

java.lang.Object
com.google.adk.agents.BaseAgent
com.google.adk.a2a.agent.RemoteA2AAgent

public class RemoteA2AAgent extends BaseAgent
Agent that communicates with a remote A2A agent via an A2A client.

The remote agent can be specified directly by providing an `AgentCard` to the builder, or it can be resolved automatically using the provided A2A client.

Key responsibilities of this agent include:

- Agent card resolution and validation
- Converting ADK session history events into A2A requests (`Message`)
- Handling streaming and non-streaming responses from the A2A client
- Buffering and aggregating streamed response chunks into ADK `Event`s
- Converting A2A client responses back into ADK format

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `RemoteA2AAgent.AgentCardResolutionError`
  Exception thrown when the agent card cannot be resolved.
  `static class`
  `RemoteA2AAgent.Builder`
  Builder for `RemoteA2AAgent`.
  `static class`
  `RemoteA2AAgent.TypeError`
  Exception thrown when a type error occurs.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static RemoteA2AAgent.Builder`
  `builder()`
  `boolean`
  `isStreaming()`
  `protected io.reactivex.rxjava3.core.Flowable<Event>`
  `runAsyncImpl(InvocationContext invocationContext)`
  Agent-specific asynchronous logic.
  `protected io.reactivex.rxjava3.core.Flowable<Event>`
  `runLiveImpl(InvocationContext invocationContext)`
  Agent-specific synchronous logic.
  `AgentEnums.AgentOrigin`
  `toolOrigin()`
  Returns the origin of the tool when this agent is used as a tool.

  ### Methods inherited from class BaseAgent

  `afterAgentCallback, beforeAgentCallback, canonicalAfterAgentCallbacks, canonicalBeforeAgentCallbacks, close, description, findAgent, findSubAgent, fromConfig, name, parentAgent, parentAgent, rootAgent, runAsync, runLive, subAgents`
  Modifier and Type
  Method
  Description
  `com.google.common.collect.ImmutableList<? extends Callbacks.AfterAgentCallback>`
  `afterAgentCallback()`
  `com.google.common.collect.ImmutableList<? extends Callbacks.BeforeAgentCallback>`
  `beforeAgentCallback()`
  `com.google.common.collect.ImmutableList<? extends Callbacks.AfterAgentCallback>`
  `canonicalAfterAgentCallbacks()`
  The resolved afterAgentCallback field as a list.
  `com.google.common.collect.ImmutableList<? extends Callbacks.BeforeAgentCallback>`
  `canonicalBeforeAgentCallbacks()`
  The resolved beforeAgentCallback field as a list.
  `io.reactivex.rxjava3.core.Completable`
  `close()`
  Closes all sub-agents.
  `final String`
  `description()`
  Gets the one-line description of the agent's capability.
  `Optional<BaseAgent>`
  `findAgent(String name)`
  Finds an agent (this or descendant) by name.
  `Optional<BaseAgent>`
  `findSubAgent(String name)`
  Recursively search sub agent by name.
  `static BaseAgent`
  `fromConfig(BaseAgentConfig config, String configAbsPath)`
  Creates a new agent instance from a configuration object.
  `final String`
  `name()`
  Gets the agent's unique name.
  `BaseAgent`
  `parentAgent()`
  Retrieves the parent agent in the agent tree.
  `protected void`
  `parentAgent(BaseAgent parentAgent)`
  Sets the parent agent.
  `BaseAgent`
  `rootAgent()`
  Returns the root agent for this agent by traversing up the parent chain.
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runAsync(InvocationContext parentContext)`
  Runs the agent asynchronously.
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runLive(InvocationContext parentContext)`
  Runs the agent synchronously.
  `List<? extends BaseAgent>`
  `subAgents()`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### builder

    public static RemoteA2AAgent.Builder builder()

  - ### isStreaming

    public boolean isStreaming()

  - ### runAsyncImpl

    protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext)
    Description copied from class: `BaseAgent`
    Agent-specific asynchronous logic.
    Specified by:
      `runAsyncImpl` in class `BaseAgent`
    Parameters:
      `invocationContext` - Current invocation context.
    Returns:
      stream of agent-generated events.

  - ### runLiveImpl

    protected io.reactivex.rxjava3.core.Flowable<Event> runLiveImpl(InvocationContext invocationContext)
    Description copied from class: `BaseAgent`
    Agent-specific synchronous logic.
    Specified by:
      `runLiveImpl` in class `BaseAgent`
    Parameters:
      `invocationContext` - Current invocation context.
    Returns:
      stream of agent-generated events.

  - ### toolOrigin

    public AgentEnums.AgentOrigin toolOrigin()
    Description copied from class: `BaseAgent`
    Returns the origin of the tool when this agent is used as a tool.
    Overrides:
      `toolOrigin` in class `BaseAgent`
    Returns:
      the tool origin, defaults to "BASE_AGENT".