A2A.Registry (A2A v0.3.0)

Copy Markdown View Source

Agent discovery registry backed by ETS.

Stores {module, card} entries where card is the plain map returned by module.agent_card/0. The GenServer owns the ETS table and handles writes; reads go directly to ETS for concurrent access.

Usage

{:ok, _pid} = A2A.Registry.start_link(name: A2A.Registry)
:ok = A2A.Registry.register(A2A.Registry, MyAgent, MyAgent.agent_card())
{:ok, card} = A2A.Registry.get(A2A.Registry, MyAgent)

Pre-populating on Start

A2A.Registry.start_link(
  name: A2A.Registry,
  agents: [MyApp.PricingAgent, MyApp.RiskAgent]
)

Each module's agent_card/0 is called during init/1 and the result is inserted into the table.

Summary

Functions

Returns all registered {module, card} entries.

Returns a specification to start this module under a supervisor.

Returns all agent modules whose card contains a skill with the given tag.

Looks up a single agent by module name.

Registers an agent module with its card.

Starts the registry process and creates the underlying ETS table.

Removes an agent module from the registry.

Functions

all(registry)

@spec all(GenServer.server()) :: [{module(), A2A.Agent.card()}]

Returns all registered {module, card} entries.

Reads ETS directly — no message passing.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

find_by_skill(registry, tag)

@spec find_by_skill(GenServer.server(), String.t()) :: [module()]

Returns all agent modules whose card contains a skill with the given tag.

Reads ETS directly — no message passing.

get(registry, module)

@spec get(GenServer.server(), module()) ::
  {:ok, A2A.Agent.card()} | {:error, :not_found}

Looks up a single agent by module name.

Reads ETS directly — no message passing.

register(registry, module, card)

@spec register(GenServer.server(), module(), A2A.Agent.card()) :: :ok

Registers an agent module with its card.

Overwrites any existing entry for the same module.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts the registry process and creates the underlying ETS table.

Options

  • :name — process/table name (required)
  • :agents — list of agent modules to pre-populate (default: [])

unregister(registry, module)

@spec unregister(GenServer.server(), module()) :: :ok

Removes an agent module from the registry.