Help us shape the future of Go! Take the 2026 Go Developer Survey

a2ax

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package a2ax drives A2A agents through the official Go A2A SDK and reports what each call returned in framework-owned types.

The conformant path of an A2A scenario is a cross-SDK interoperability check: a client built on the reference Go SDK talks, through the gateway, to an agent built on the reference Python SDK. Hand-built JSON-RPC envelopes and REST paths would make both sides of that check the test's own reading of the specification, so a field name misread the same way twice would pass. Requests a conformant client cannot produce, such as a missing protocol version or an unknown method, belong on the ordinary HTTP funnel instead.

Every Client is bound to exactly one endpoint and one protocol binding, with the SDK's transport defaults disabled, so a client asked for JSON-RPC cannot fall back to HTTP+JSON and turn a scenario claiming both bindings into one that exercised one binding twice. A Client is never built by following the URL inside a card unless the caller asks for that explicitly through InterfaceURL: a passthrough card advertises the upstream agent's own address, and a client that followed it would bypass the gateway entirely.

SDK results are converted into Outcome values rather than re-encoded as response bytes, so an assertion over them can never be mistaken for an assertion over what the gateway returned. A failed call is recorded in Outcome.Err rather than returned, because whether a call was meant to be refused is the caller's assertion to make.

Index

Constants

View Source
const (
	BindingJSONRPC  = string(a2a.TransportProtocolJSONRPC)
	BindingHTTPJSON = string(a2a.TransportProtocolHTTPJSON)
)

Protocol bindings a Client can be bound to, spelled as an Agent Card and an Agent resource spell them.

View Source
const (
	DefaultCallTimeout   = 30 * time.Second
	DefaultStreamTimeout = 60 * time.Second
)

Default bounds for one SDK call. They are stuck-test backstops rather than assertions: a call that should succeed and does not is reported with the SDK's own error long before either fires.

Variables

This section is empty.

Functions

func InterfaceURL

func InterfaceURL(card []byte, binding string) (string, error)

InterfaceURL returns the URL an Agent Card advertises for one binding, the way a real client bootstraps from a card.

Types

type Card

type Card struct {
	Name   string
	Skills []string
}

Card is the part of an Agent Card a scenario asserts on.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is one SDK client bound to one endpoint and one protocol binding.

func NewClient

func NewClient(ctx context.Context, binding, url string, opts Options) (*Client, error)

NewClient builds a client for exactly one endpoint and one binding.

func (*Client) Binding

func (c *Client) Binding() string

Binding returns the protocol binding the client speaks.

func (*Client) CancelTask

func (c *Client) CancelTask(ctx context.Context, headers Headers, taskID string) *Outcome

CancelTask cancels one task.

func (*Client) Close

func (c *Client) Close() error

Close releases the client's connections. It is safe to call on a nil or closed client.

func (*Client) CreatePushConfig

func (c *Client) CreatePushConfig(ctx context.Context, headers Headers, taskID, configID, url string) *Outcome

CreatePushConfig registers a push notification config for a task.

func (*Client) DeletePushConfig

func (c *Client) DeletePushConfig(ctx context.Context, headers Headers, taskID, configID string) *Outcome

DeletePushConfig removes one push notification config of a task.

func (*Client) GetExtendedCard

func (c *Client) GetExtendedCard(ctx context.Context, headers Headers) *Outcome

GetExtendedCard fetches the authenticated extended Agent Card.

func (*Client) GetPushConfig

func (c *Client) GetPushConfig(ctx context.Context, headers Headers, taskID, configID string) *Outcome

GetPushConfig fetches one push notification config of a task.

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, headers Headers, taskID string) *Outcome

GetTask fetches one task.

func (*Client) ListPushConfigs

func (c *Client) ListPushConfigs(ctx context.Context, headers Headers, taskID string) *Outcome

ListPushConfigs lists the push notification configs of a task.

func (*Client) ListTasks

func (c *Client) ListTasks(ctx context.Context, headers Headers) *Outcome

ListTasks lists the tasks the agent holds.

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, headers Headers, text string, returnImmediately bool) *Outcome

SendMessage sends one user text message. returnImmediately asks the agent to answer as soon as the task exists, which is the only way to obtain a task that is still running.

func (*Client) StreamMessage

func (c *Client) StreamMessage(ctx context.Context, headers Headers, text string) *Outcome

StreamMessage sends one user text message as a stream and drains it to its end.

func (*Client) SubscribeToTask

func (c *Client) SubscribeToTask(ctx context.Context, headers Headers, taskID string, maxEvents int) *Outcome

SubscribeToTask re-attaches to a task and stops after maxEvents events.

Bounded by events rather than by the terminal state: the task it attaches to is normally still running, so reading to the end would wait out the agent's whole hold. maxEvents must be positive.

func (*Client) URL

func (c *Client) URL() string

URL returns the endpoint the client dials.

type Event

type Event struct {
	// Type is the event kind: task, message, status-update or artifact-update.
	Type string
	// State is the task state the event carries, empty when it carries none.
	State string
	// Text is the event rendered as the text a scenario asserts on.
	Text string
	// TaskID is the task the event belongs to, empty when it names none.
	TaskID string
	// Artifact is the artifact text an artifact-update event carries.
	Artifact string
	Offset   time.Duration
}

Event is one streamed event and when it was handed to the caller, measured from the start of the call. A response held whole and released at the end yields every event at effectively the same offset, which is what keeps buffering observable through the SDK.

type Headers

type Headers map[string]string

Headers are request headers attached to a call, such as the credentials a scenario set. They are read per call, so a token obtained after the client was built still applies.

type Options

type Options struct {
	// ProtocolVersion is the A2A version the client states on every request. It is required:
	// the gateway rejects an operation whose stated version is not the one its Agent exposes,
	// so a defaulted value would make the rejection path the one a scenario exercises.
	ProtocolVersion string
	// CallTimeout bounds one unary call. Zero selects DefaultCallTimeout.
	CallTimeout time.Duration
	// StreamTimeout bounds one streamed call, including the time spent waiting for events.
	// Zero selects DefaultStreamTimeout.
	StreamTimeout time.Duration
}

Options configure a Client.

type Outcome

type Outcome struct {
	Method string
	Err    error

	Task        *Task
	Message     *string
	Tasks       []Task
	Card        *Card
	PushConfig  *PushConfig
	PushConfigs []PushConfig

	Events         []Event
	StreamDuration time.Duration
}

Outcome is the typed result of one call. Exactly one payload field is populated per call, or Err is set.

func (*Outcome) ArtifactText

func (o *Outcome) ArtifactText() (string, error)

ArtifactText concatenates the text of every artifact the outcome carries, whether it arrived on a task or as streamed artifact-update events.

func (*Outcome) FinalState

func (o *Outcome) FinalState() (string, error)

FinalState returns the task state carried by the last streamed event.

func (*Outcome) Kind

func (o *Outcome) Kind() string

Kind names what the outcome carries, for an assertion message.

func (*Outcome) Summary

func (o *Outcome) Summary() string

Summary renders the streamed events with their arrival offsets, for an assertion message.

func (*Outcome) TaskID

func (o *Outcome) TaskID() string

TaskID returns the task the outcome concerns: the returned task's, or else the last streamed event that named one. It is empty when the call produced no task.

type PushConfig

type PushConfig struct {
	ID     string
	TaskID string
}

PushConfig identifies one push notification config.

type Task

type Task struct {
	ID        string
	ContextID string
	// State is the protocol's state name, such as TASK_STATE_COMPLETED.
	State string
	// Terminal reports whether the state admits no further change.
	Terminal bool
	// Artifacts holds the text of each artifact, one entry per artifact.
	Artifacts []string
}

Task is the part of an A2A task a scenario asserts on.

Jump to

Keyboard shortcuts

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