Skip to main content

Module a2a_compat

Module a2a_compat 

Source
Expand description

A2A-compatible event mapping boundary for collaboration transport.

This module defines the CollaborationTransport trait that abstracts the transport layer for CollaborationEvents, and provides a LocalTransport implementation backed by an in-process broadcast channel.

§A2A Concept Mapping

The collaboration event model is designed to map cleanly onto the ADK A2A protocol (see adk-server/src/a2a/types.rs) for future remote specialist execution. The mapping is:

Collaboration ConceptA2A Concept
CollaborationEventA2A Message or TaskStatusUpdateEvent
correlation_idA2A task_id — links related events into one task
producerA2A agent card sender — the agent originating the event
consumerA2A agent card receiver — the intended recipient agent
kindA2A TaskState or message role (see kind mapping below)
payloadA2A Artifact parts or Message parts (structured data)
topicA2A message metadata or artifact name
timestampA2A event timestamp

§Event Kind → A2A Task State Mapping

[CollaborationEventKind]A2A TaskStateNotes
NeedWorkSubmittedA new task is submitted for another agent
WorkClaimedWorkingThe receiving agent has accepted the task
WorkPublishedCompleted + artifactTask completed with output artifact
FeedbackRequestedInputRequiredAgent needs input before continuing
FeedbackProvidedSubmitted (response)Input provided as a new message
BlockedInputRequired + metadataAgent blocked, needs external decision
CompletedCompleted (final)Terminal state, no more updates

§Transport Neutrality

Phase 1 uses LocalTransport (in-process broadcast channel). The event envelope is transport-neutral: the same CollaborationEvent struct works whether the transport is local or remote. A future A2aTransport would serialize events into A2A JSON-RPC messages and route them over HTTP/SSE without changing the CollaborationTransport trait contract.

§Migration Path to A2A

To add remote specialist execution later:

  1. Implement CollaborationTransport backed by an A2A client
  2. Map CollaborationEvent → A2A Message on publish
  3. Map A2A TaskStatusUpdateEvent / TaskArtifactUpdateEventCollaborationEvent on receive
  4. Use correlation_id as the A2A task_id for routing
  5. Use producer/consumer to resolve agent card URLs

The [Workspace] API remains unchanged — only the transport implementation swaps from local to remote.

§Example

use adk_code::a2a_compat::{CollaborationTransport, LocalTransport};
use adk_code::{CollaborationEvent, CollaborationEventKind};

let transport = LocalTransport::new(64);
let mut receiver = transport.subscribe();

let event = CollaborationEvent::new(
    "corr-1", "api-routes", "backend", CollaborationEventKind::WorkPublished,
);
transport.publish(event).await.unwrap();

let received = receiver.recv().await;
assert!(received.is_some());

Structs§

LocalTransport
In-process collaboration transport backed by a broadcast channel.

Traits§

CollaborationReceiver
Async trait for receiving collaboration events from a transport.
CollaborationTransport
Async trait abstracting the collaboration event transport layer.