Skip to main content

Module spawn

Module spawn 

Source
Expand description

Spawn an autonomous A2A agent runtime with auto peer discovery.

Stands up an A2AServer (Axum) on a configurable host:port, publishes an agent card at /.well-known/agent.json, and runs a background discovery loop that polls each --peer seed for its agent card. New peers are registered in the local bus and (unless --no-auto-introduce is set) sent a one-shot non-blocking message/send introduction.

Each spawned process is a self-contained A2A node: there is no central broker. Two codetether spawn instances pointing at each other form the minimal mesh; n instances form a fully-connected mesh as long as the seed graph is connected.

§Lifecycle

  1. Resolve identity (--name, bind addr, public URL).
  2. Build the default AgentCard and let --description override the default text.
  3. Initialize AgentBus, start the best-effort training-record S3 sink, register self in the registry, and announce-ready with the card’s skill ids as capabilities.
  4. Spawn [discovery_loop] for --peer seeds.
  5. Bind the A2AServer::router and serve until SIGINT.
  6. On shutdown: abort discovery and exit cleanly.

§Discovery

Every discovery_interval_secs (clamped to ≥ 5):

  • For each seed, build candidates via [peer_candidates] (tries seed and seed/a2a unless the seed already ends in /a2a).
  • First successful agent-card fetch wins; the card is registered in bus.registry.
  • On first sighting of a given endpoint::card.name pair: emit Discovered A2A peer and (if auto_introduce) call [send_intro] over the A2A client.
  • Re-sightings re-register the card (refresh) but do not re-introduce.

Outbound discovery and intro calls attach CODETETHER_AUTH_TOKEN as a bearer if set.

§See also

Full prose documentation lives at docs/a2a-spawn.md (CLI reference, HTTP/JSON-RPC API, curl recipes, cross-host setup, troubleshooting, source map).

Structs§

A2APeerHandle
Handle to A2A peer background tasks (server + discovery loop + mDNS).
SpawnOptions
Inputs for starting an A2A peer runtime.

Functions§

auto_agent_name
Auto-derive a stable, human-readable agent name from <short-host>-<repo-basename>-<short-pid>. Falls back gracefully if any component is unavailable.
run
Run the codetether spawn command. Owns its own bus and S3 sink, blocks on ctrl_c with graceful shutdown.
start_a2a_in_background
Start an A2A peer runtime in the background, attached to the given bus.