# `ADK.Agent`
[🔗](https://github.com/zeroasterisk/adk-elixir/blob/main/lib/adk/agent.ex#L1)

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

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `description`

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

Human-readable description.

# `name`

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

Agent name identifier.

# `run`

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

Execute the agent, returning a list of events.

# `sub_agents`

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

Child agents for delegation.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
