Skip to content

feat(a2acli): add collaborate subcommand (Basic Relay §2.1) - #578

Open
Tehsmash wants to merge 3 commits into
feat/a2a-collab-cratefrom
feat/a2acli-collaborate
Open

Tehsmash wants to merge 3 commits into
feat/a2a-collab-cratefrom
feat/a2acli-collaborate

Conversation

@Tehsmash

Copy link
Copy Markdown
Collaborator

Summary

New a2acli collaborate subcommand implementing the Basic Relay model from spec §2.1.

a2acli collaborate \
  --agent http://localhost:9001 \
  --agent http://localhost:9002 \
  --agent http://localhost:9003 \
  "Customer ORD-1001 has not received their order — what is going on?"

Behavior

  1. Resolve each --agent reference to its AgentCard
  2. Pre-flight: require_collaborative_extensions on each card — fails fast if any agent missing both required URIs
  3. Build initial SendMessageRequest from parts (same --text-part/--file-part/--data-part flags as send)
  4. Stream initial message to all agents simultaneously
  5. Merge all streams. For each event:
    • Print to stdout: [agent-name] <rendered-event> (or JSONL with agent field under -o json)
    • Relay translated copy to every other agent via translate_peer_response() + send_message(return_immediately=true)
  6. Echo suppression: skip originating agent
  7. Respects global --timeout

Changes

  • a2acli/Cargo.toml: add a2a-collab dependency
  • a2acli/src/lib.rs: CollaborateCommand struct, Collaborate enum variant, run_collaborate_command(), resolve_collaborate_parts(), fetch_card_for_reference()

All existing 123 tests pass.

Depends on #577. Closes #572. Part of #569.

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 100 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
a2acli/src/lib.rs 0.00% 100 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Tehsmash
Tehsmash force-pushed the feat/a2acli-collaborate branch from 00965bc to ba6256d Compare November 20, 2026 13:33
New `a2acli collaborate` subcommand implementing the Basic Relay model
from the A2A collaborative task spec §2.1. Works with any A2A transport.

Usage:
  a2acli collaborate --agent CARD1 --agent CARD2 "initial message"

- Pre-flight check: verify every agent declares both required extension
  URIs (EXTENSION_URI_SHARED_TASK + EXTENSION_URI_COLLABORATIVE_TASK)
  before opening any connections.
- Streams initial message to all agents simultaneously.
- Merges streams with select_all; for each event: prints to stdout with
  agent label prefix, then relays a translated copy to every other agent
  (echo suppression). Uses return_immediately=true for relay injection.
- Caches each agent's context_id/task_id from first Task event for
  session ID rewriting.
- Respects global --timeout.
- Supports -o json (JSONL with agent field) and -o text (prefixed lines).

Depends on a2a-collab crate for translate_peer_response() and
require_collaborative_extensions().

Closes #572. Part of #569.

Signed-off-by: Sam Betts <1769706+Tehsmash@users.noreply.github.com>
…sion

Replace the manual relay loop in run_collaborate_command with
CollaborativeSession::new(agents).start(initial_request).await.
The relay logic (stream merge, session ID caching, echo suppression,
translate_peer_response dispatch) now lives in a2a-collab where it belongs.

CLI retains responsibility for: timeout loop, output formatting, and
injecting cli.tenant into each client via with_tenant().

Signed-off-by: Sam Betts <1769706+Tehsmash@users.noreply.github.com>
Signed-off-by: Sam Betts <1769706+Tehsmash@users.noreply.github.com>
@Tehsmash
Tehsmash force-pushed the feat/a2acli-collaborate branch from ba6256d to c325d00 Compare November 20, 2026 16:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(a2acli): add collaborate subcommand (Basic Relay §2.1)

1 participant