a2a.go

Overview

The a2a.go file implements an Agent-to-Agent (A2A) sublauncher that integrates A2A capabilities into the web server framework. It extends the web launcher system by adding HTTP endpoints for distributed multi-agent communication using the A2A protocol. This includes serving a static agent card describing the root agent's capabilities and exposing a JSON-RPC handler for A2A invocations.

The A2A sublauncher enables clients or other agents to invoke the local agent remotely via the A2A protocol over HTTP. It acts as a bridge between the internal agent execution framework and external distributed workflows, supporting streaming and JSON-RPC communication.

This file is part of the broader API and A2A Sublaunchers topic under the REST API and Web Launchers module, focusing on modular extensions of the web server for agent interaction protocols.


Types and Structures

a2aConfig

type a2aConfig struct {
	agentURL string // Public URL advertised in the agent card for A2A invocation endpoint
}

a2aLauncher

type a2aLauncher struct {
	flags  *flag.FlagSet  // Command-line flag parser specific to this sublauncher
	config *a2aConfig     // Configuration instance with parsed flag values
}

Functions and Methods

NewLauncher() web.Sublauncher

func NewLauncher() web.Sublauncher
launcher := a2a.NewLauncher()

(a *a2aLauncher) CommandLineSyntax() string

func (a *a2aLauncher) CommandLineSyntax() string

(a *a2aLauncher) Keyword() string

func (a *a2aLauncher) Keyword() string

(a *a2aLauncher) Parse(args []string) ([]string, error)

func (a *a2aLauncher) Parse(args []string) ([]string, error)
args, err := a2aLauncher.Parse(os.Args[1:])
if err != nil {
    // handle error
}

(a *a2aLauncher) SetupSubrouters(router *mux.Router, config *launcher.Config) error

func (a *a2aLauncher) SetupSubrouters(router *mux.Router, config *launcher.Config) error

This method is the core integration point where the A2A protocol is exposed over HTTP.


(a *a2aLauncher) SimpleDescription() string

func (a *a2aLauncher) SimpleDescription() string

(a *a2aLauncher) UserMessage(webUrl string, printer func(v ...any))

func (a *a2aLauncher) UserMessage(webUrl string, printer func(v ...any))

Important Implementation Details


Interaction with Other Parts of the System


Usage Example

To run the A2A sublauncher as part of the web server, the command-line might include:

./server -a2a -a2a_agent_url="https://myagent.example.com"

This configures the A2A server to advertise its public endpoint as https://myagent.example.com/a2a/invoke. Clients can then query https://myagent.example.com/.well-known/agentcard to retrieve agent capabilities and invoke agents via JSON-RPC at /a2a/invoke.


Visual Diagram: A2A Sublauncher Structure and Workflow

classDiagram
class a2aLauncher {
-flags
-config
+CommandLineSyntax()
+Keyword()
+Parse()
+SetupSubrouters()
+SimpleDescription()
+UserMessage()
}
class a2aConfig {
-agentURL
}
a2aLauncher --> a2aConfig
a2aLauncher ..> mux.Router : SetupSubrouters(router)
a2aLauncher ..> adka2a.Executor : creates executor
a2aLauncher ..> a2asrv.Handler : creates JSON-RPC handler
a2aLauncher ..> a2acore.AgentCard : builds static agent card

Summary of Key Constants and Variables

Name

Type

Description

apiPath

string

Fixed URL suffix /a2a/invoke for JSON-RPC endpoint


References to Related Topics


This file is a critical component enabling distributed, protocol-compliant remote agent invocation, enhancing the system’s ability to operate in multi-agent, networked environments.