Current section
Files
Jump to
Current section
Files
docs/home.md
# Build agents with Elixir
<div class="exagent-intro">
<p class="exagent-kicker">ExAgent 3.0 · Elixir / OTP</p>
<p class="exagent-lead">Start with one function call.<br>Add OTP supervision, approvals and coordination only when you need them.</p>
<p>Define tools as ordinary Elixir functions, validate structured output with Ecto changesets, stream live updates into Phoenix, and pause high-risk tool calls for human approval across deploys — all over one coherent agent loop powered by stock ReqLLM.</p>
</div>
[Run your first agent →](guides/getting-started.md){: .exagent-primary}
[How ExAgent works](guides/mental-model.md)
[For LLMs & coding agents](guides/agents.md)
{: .exagent-actions}
> #### Package version {: .info}
>
> These pages document **ExAgent 3.0**. Upgrading from 1.x or 2.x? Read
> [Migration](guides/migration.md) and check
> [Supported features and limits](guides/support.md).
## A small, working beginning
Run this inside any Mix project with `{:exagent, "~> 3.0.0"}` — no API keys,
database or network needed:
```elixir
agent = ExAgent.new(model: "test", instructions: "Be concise.")
{:ok, result} = ExAgent.run(agent, "Hello!")
result.output
# => "a test response"
```
`"test"` runs the exact same loop as Anthropic, OpenAI, Gemini, OpenRouter,
Ollama or vLLM. Once your app handles results cleanly, swap `model:` to a real
provider without changing a single line of business logic.
## What ExAgent simplifies
Building production agents in Elixir usually forces you to hand-roll the same
plumbing over and over: JSON Schema generation, changeset retry loops when a
model emits malformed JSON, streaming GenServers with backpressure, crash-safe
human approvals that never double-execute a side effect, and offline test
harnesses. ExAgent turns each of those into an opt-in layer:
<dl class="exagent-layers">
<div><dt>1. Run</dt><dd><strong>What it gives you:</strong> Stateless tool loops and Ecto-validated typed outputs.<br><strong>What it simplifies:</strong> No hand-written JSON Schemas, manual retry loops or raw HTTP parsing. Start here for extraction, classification and Oban jobs.</dd></div>
<div><dt>2. Server</dt><dd><strong>What it gives you:</strong> Supervised conversations with history, bounded queues, streaming deltas, Phoenix LiveView scaffolding and SSE / AI SDK / AG-UI adapters.<br><strong>What it simplifies:</strong> No custom GenServer state machines for cancellation, backpressure or reconnection.</dd></div>
<div><dt>3. Store & Approvals</dt><dd><strong>What it gives you:</strong> Confirmed checkpoints (ETS for in-VM dev/tests, PostgreSQL for production) and explicit pause/resume boundaries.<br><strong>What it simplifies:</strong> Survive crashes and deploys with PostgreSQL without ever replaying an unconfirmed payment, email or mutation.</dd></div>
<div><dt>4. Coordination</dt><dd><strong>What it gives you:</strong> Scoped delegation, handoffs, shared-state sessions and durable multi-step workflows.<br><strong>What it simplifies:</strong> Compose specialists with inherited budgets, permissions and cancellation instead of ad-hoc message passing.</dd></div>
</dl>
Unsure which layer fits your problem? Read [Mental model and architecture](guides/mental-model.md)
for a 5-minute walkthrough and a concrete pattern decision table.
## Learn by task
| What you want to build | Start here |
|---|---|
| Understand how every piece fits together | [Mental model and architecture](guides/mental-model.md) |
| Install ExAgent and run your first agent | [Getting started](guides/getting-started.md) |
| Call Elixir functions as tools and return Ecto structs | [Tools and structured output](guides/tools-and-output.md) |
| Pick cloud or local models (Ollama/vLLM) and set budgets | [Models, budgets and limits](guides/models-and-limits.md) |
| Stream responses, manage conversations and wire LiveView | [Runtime and events](guides/runtime-and-events.md) |
| Persist runs and pause for human approval across restarts | [Durability and approvals](guides/durability-and-approvals.md) |
| Delegate work, hand off turns or run multi-agent workflows | [Coordination](guides/coordination.md) |
| Load task instructions on demand or remember users across turns | [Skills](guides/skills.md) · [Long-term memory](guides/memory.md) |
| Test deterministically in CI and run evaluations | [Testing and evaluations](guides/testing.md) |
| Export traces to OpenTelemetry, Langfuse or Opik | [Observability](guides/observability.md) |
| Connect external MCP tool servers or expose your own | [MCP](guides/mcp.md) |
| Diagnose an error or inspect your setup | [Troubleshooting](guides/troubleshooting.md) |
## Two documentation tracks: humans and LLMs
ExAgent ships two distinct documentation tracks generated from the same release:
- **For human developers** — Start with [Mental model](guides/mental-model.md),
[Getting started](guides/getting-started.md) and the task guides above. Each
guide focuses on *what* a feature does, *why* it helps and *how* to use it
with complete, realistic Elixir examples.
- **For LLMs and coding agents** — Point your AI assistant at
[Coding-agent integration notes](guides/agents.md), the machine-dense contract
sheets ([Tools & models contracts](guides/llm/tools-and-models-contracts.md)
and [Runtime & ops contracts](guides/llm/runtime-and-ops-contracts.md)), or
sync the bundled `usage-rules.md` and 11 package skills directly into your
repository with `mix usage_rules.sync`. ExDoc also publishes `llms.txt`,
single-fetch `llms-full.txt` and per-page Markdown files (see the links in the
footer).
Browse the **Modules** tab or press **/** for the complete API reference, or
open the [Documentation index](guides/index.md) for the full map including
Phoenix, Oban and OTLP integration recipes.