striking

striking

Alloy 0.8.0 - Minimal, OTP-native agent loop for Elixir

Alloy 0.8.0 The model-agnostic agent engine for Elixir

Alloy is a minimal agent loop for building AI agents on the BEAM. Think of it as the completion-tool-call loop and nothing else, no opinions on sessions, persistence, or UI.

What’s new in 0.8.0

Cost guard pass max_budget_cents: 50 to Alloy.run/2 and the loop halts with :budget_exceeded status before your agent overspends. The check runs at the start of each turn alongside max_turns.

{:ok, result} = Alloy.run("Research this codebase",
  provider: {Alloy.Provider.Anthropic, api_key: key, model: "claude-sonnet-4-6"},
  tools: [Alloy.Tool.Core.Read, Alloy.Tool.Core.Bash],
  max_budget_cents: 50
)
# result.status => :budget_exceeded | :completed

Summary-based context compaction when conversations approach the token limit, Alloy generates a structured handoff summary of older context instead of truncating. The summary preserves progress, key decisions, constraints, and next steps. Falls back to deterministic truncation if summary generation fails.

Compaction is now configurable:

Alloy.run(input,
  provider: provider,
  compaction: [
    reserve_tokens: 12_000,       # Room for the next response
    keep_recent_tokens: 8_000,    # Recent messages kept verbatim
    fallback: :truncate           # When summary fails
  ]
)

One-shot streaming Alloy.stream/3 gives you token-by-token output without managing a GenServer:

{:ok, result} = Alloy.stream("Explain OTP", fn chunk ->
  IO.write(chunk)
end, provider: {Alloy.Provider.OpenAI, api_key: key, model: "gpt-5.4"})

Why model-agnostic matters

Alloy works with Anthropic, OpenAI (Responses API), xAI/Grok, Gemini, and any OpenAI-compatible endpoint (Ollama, OpenRouter, DeepSeek, Mistral, Groq). Swap providers by changing one line — your tools, prompts, and agent logic stay the same.

Today’s best model might not be tomorrow’s. Building on Alloy means you can switch without rewriting your agent.

The philosophy

Inspired by Pi Agent’s minimalism: 4 built-in tools (read, write, edit, bash), a good prompt, and a loop. That’s the framework. ~5,000 lines, small enough to read and understand in an afternoon.

OTP gives us the rest for free: supervision trees for fault tolerance, Task.Supervisor for parallel tool execution, PubSub for event streaming, GenServer for stateful agents.

Links

Feedback, issues, and PRs welcome. Happy to answer questions about the architecture.

Where Next?

Popular in News & Updates Top

fhunleth
It looks like it’s finally safe to announce that Nerves supports Erlang/OTP 26 and Elixir 1.15! We’ve updated dozens of Nerves and close...
New
bartblast
Hologram UI is in the works - the official component library for Hologram - and the waiting list is now open. A common reaction when I m...
New
zachdaniel
What if you had full stack types for SPAs built with tech like React, Inertia, Vue, Svelte… but all of the power Ash Framework and Elixir...
New
bartblast
After building Hologram and sharing updates across various places, I’ve realized there’s a lot happening that doesn’t always make it to t...
New
fhunleth
Nerves systems provide the operating system, libraries and other tools for building firmware for specific hardware. The Nerves Core Team ...
New
hwuethrich
Hi! I’m happy to share my first Elixir library. But first some … Background As an Elixir company from a country with 4 official languag...
New
jimsynz
It’s been a long time coming, but Reactor has finally reached 1.0. For those unfamiliar, Reactor is a dynamic, concurrent, dependency-re...
New
fhunleth
We recently released Nerves 1.5.0 and corresponding updates to the Nerves new project generator, nerves_bootstrap and our official system...
New
zachdaniel
Hey folks! In order to give the new AshSqlite a trial run and make sure its got some real usage, AshHq’s multi-package search has been re...
New
zachdaniel
Hey folks! I’ll be teasing some interesting bits going into Ash 3.0 while I work on it, and this is post #1! You can follow along with t...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53578 245
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement