Skip to content

A2A Client Agent

The A2AClientAgent in the AI Refinery SDK adds Agent2Agent Protocol (A2A) support, enabling seamless communication and collaboration between AI agents. It allows AIR agents to interact with external agents via the A2A protocol, acting as a mediator for standardized communication. For more details, check the A2A server introduction, and explore our representative A2A servers in A2A server catalog.

Workflow Overview

Being a Utility Agent, the A2AClientAgent can be invoked either directly by the orchestrator or by a Super Agent. Its capabilities include:

  • Agent Interaction: Connects to external A2A agents, identifies those with A2A capabilities, and facilitates seamless communication and collaboration.

  • Enhanced Response Features: Supports advanced response functionalities such as streaming and tracing to ensure efficient and transparent agent interactions.

  • Secure Authentication: Supports authentication to access extended capabilities of A2A agents, ensuring secure and reliable communication.

Usage

The A2AClientAgent can be easily incorporated into a project by updating the project's YAML file with the necessary configuration. It should be included in the list of available Utility Agents, allowing it to be utilized by the orchestrator or its designated Super Agent.

Quickstart

To quickly set up a project with an A2AClientAgent, you first need to make sure that the A2A servers that the agent will connect to are running. If the servers are running locally, you need to make sure you expose the servers over separate ports from each other. Then, you can use the following YAML configuration template to allow the agent to connect to the servers and utilize their tools.

orchestrator:
  agent_list:
    - agent_name: "Chat Agent"  # A customized chat conversation agent
    - agent_name: "Currency Converter"  # An agent for retrieving currency exchange rates

utility_agents:
  - agent_class: A2AClientAgent  # The class should be A2AClientAgent
    agent_name: "Chat Agent"  # Should match the agent_name in orchestrator
    agent_description: "A customized chat conversation agent. Forward all general queries to this agent for a response." # Description of functionality
    config:
      base_url: 'http://localhost:9999'  # Required: User defined local URL of the A2A server exposing custom chat agent's services
      agent_card:  # Required: Details of the agent card retrieval (this is an external agent)
        public:  # Required: Type of the agent card (can be either public or private; here it is public)
          public_agent_card_path: "/.well-known/agent.json"  # Required: Path to the agent card
          rpc_url: "http://localhost:9999"  # Required: Corresponding URL of the agent card
      response_prefs:  # Required: The response preferences
        tracing: False  # Required: For disabling intermediate agent responses
        streaming: False  # Required: For agent responses 
      wait_time: 300  # Optional: Time (in seconds) the agent waits for A2A server response
      contexts:  # Optional additional agent contexts
        - "date"
        - "chat_history"

  - agent_class: A2AClientAgent  # The class should be A2AClientAgent
    agent_name: "Currency Converter"  # Should match the agent_name in orchestrator
    agent_description: "A currency-converter agent. Forward all currency-related queries to that one." # Description of functionality
    config:
      base_url: 'http://0.0.0.0:10000'  # Required: User defined local URL of the A2A server providing currency exchange API's services
      agent_card:  # Required: Details of the agent card retrieval (this is an external agent)
        public:  # Required: Type of the agent card (can be either public or private; here it is public)
          public_agent_card_path: "/.well-known/agent.json"  # Required: Path to the agent card
          rpc_url: "http://0.0.0.0:10000"  # Required: Corresponding URL of the agent card
      response_prefs:  # Required: The response preferences
        tracing: False  # Required: For disabling intermediate agent responses
        streaming: False  # Required: For agent responses 
      wait_time: 300  # Optional: Time (in seconds) the agent waits for A2A server response
      contexts:  # Optional additional agent contexts
        - "date"
        - "chat_history"

Template YAML Configuration of A2AClientAgent

In this setup, we have a single A2A Client agent that is made available to the orchestrator.

orchestrator:
  agent_list:
    - agent_name: <Name of the Agent>  # The characteristic name of the agent

utility_agents:
  - agent_class: A2AClientAgent
    agent_name: <Name of the Agent>  # The name of the agent that needs to coincide with the one listed under the orchestrator
    agent_description: <Description of the Agent>  # Description of functionality
    config:
      base_url: "http://localhost:<PORT>"  # Required: URL specifying where the server of the agent is hosted. 
      agent_card:  # Required: Supporting card retrieval. It can be either public or private:
        public:  # Required: Type of the agent card retrieval. If it is public, it has the following attributes:
          public_agent_card_path: <Directory Address> # Required: Path to the agent card
          rpc_url: <URL>  # Required: Corresponding URL of the agent card 
        private:  # Required: Type of the agent card retrieval. If it is private, it has the following attributes:
          extended_agent_card_path: <Directory Address> # Required: Path to the agent card
          authentication_token: <Token>  # Required: Corresponding authentication token for the agent card
      response_prefs:  # Required: The response preferences:
        tracing: <Boolean>  # Required: For enabling intermediate agent responses
        streaming: <Boolean>  # Required: For agent responses 
      wait_time: 300  # Optional: Time that the agent waits for a response from the A2A server.
      contexts:  # Optional additional agent contexts
        - "date"
        - "chat_history"