a2a-agent

command
v2.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

A2A Agent Example

Connect to remote A2A (Agent-to-Agent) agents with authentication via the PromptKit SDK.

What You'll Learn

  • Builder pattern with NewA2AAgent() for remote agent configuration
  • Bearer token authentication with WithAuth()
  • Custom headers with WithHeader()
  • Skill filtering to expose only specific agent skills
  • Retry policies for resilient connections

Prerequisites

  • Go 1.26+
  • An API key for one of: OpenAI, Anthropic, or Google (the packs do not pin a provider)
  • A running A2A agent (this example uses the echo server from server/a2a/examples/a2a-auth-test)

Running the Example

# Terminal 1: Start the echo server
go run ./server/a2a/examples/a2a-auth-test/server

# Terminal 2: Run this example
export OPENAI_API_KEY=your-key
go run .

Code Overview

echoAgent := sdk.NewA2AAgent("http://localhost:9877").
    WithAuth("Bearer", "test-token-123").
    WithHeader("X-Request-Source", "sdk-example").
    WithTimeout(5000).
    WithRetryPolicy(3, 100, 2000).
    WithSkillFilter(&tools.A2ASkillFilter{
        Allowlist: []string{"echo"},
    })

conv, err := sdk.Open("./a2a-agent.pack.json", "assistant",
    sdk.WithA2AAgent(echoAgent),
)

Builder Options

Method Description
WithAuth(scheme, token) Set auth credentials (e.g. Bearer token)
WithAuthFromEnv(scheme, envVar) Auth token from environment variable
WithHeader(key, value) Add a static header to all requests
WithHeaderFromEnv(headerEnv) Header value from environment variable
WithTimeout(ms) Request timeout in milliseconds
WithRetryPolicy(max, initialMs, maxMs) Exponential backoff retry policy
WithSkillFilter(filter) Allowlist/blocklist for agent skills

Tool Naming

A2A tools are namespaced as a2a__<agent>__<skill>:

  • a2a__echo_agent__echo
  • a2a__echo_agent__reverse (blocked by skill filter in this example)

Environment Variables

Variable Default Description
ECHO_AGENT_URL http://localhost:9877 Echo server URL
ECHO_AGENT_TOKEN test-token-123 Bearer token for auth

Key Concepts

  1. Auto-Discovery - Agent skills are discovered from the agent card at startup
  2. Skill Filtering - Expose only the skills you need
  3. Authentication - Bearer, Basic, or custom auth schemes
  4. Retry Policy - Exponential backoff for transient failures
  5. No Pack Changes - A2A tools don't need to be defined in the pack file

Next Steps

Documentation

Overview

Package main demonstrates connecting to A2A (Agent-to-Agent) remote agents via the SDK.

This example shows:

  • Builder pattern with NewA2AAgent for auth, headers, timeouts, retry, and skill filters
  • Bearer token authentication
  • Skill filtering (expose only "echo", hide "reverse")

Run with:

# First start the echo server (from server/a2a/examples/a2a-auth-test):
go run ./server/a2a/examples/a2a-auth-test/server

# Then run this example:
export OPENAI_API_KEY=your-key
go run .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL