ADK.Agent protocol (ADK v0.0.1-alpha.1)

Copy Markdown View Source

The core agent protocol. Every agent type implements this.

Each agent is a struct with at minimum a name field. The protocol provides polymorphic dispatch for running agents and accessing metadata.

Implementing a custom agent

defmodule MyAgent do
  @enforce_keys [:name]
  defstruct [:name, description: "", sub_agents: []]

  defimpl ADK.Agent do
    def name(agent), do: agent.name
    def description(agent), do: agent.description
    def sub_agents(agent), do: agent.sub_agents
    def run(agent, ctx), do: [ADK.Event.new(%{author: agent.name, content: "hello"})]
  end
end

Summary

Types

t()

All the types that implement this protocol.

Functions

Human-readable description.

Agent name identifier.

Execute the agent, returning a list of events.

Child agents for delegation.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

description(agent)

@spec description(t()) :: String.t()

Human-readable description.

name(agent)

@spec name(t()) :: String.t()

Agent name identifier.

run(agent, ctx)

@spec run(t(), ADK.Context.t()) :: [ADK.Event.t()]

Execute the agent, returning a list of events.

sub_agents(agent)

@spec sub_agents(t()) :: [t()]

Child agents for delegation.