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?

Trending in News & Updates Top

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
kip
I’m a bit excited to announce that Localize and friends are now at release 1.0. Even though it’s a 1.0 release, it stands on 8 years of w...
New
nseaSeb
Just published search_ash 0.5.0 (with search_core 0.4.0) on Hex. What’s new: synonyms You can now declare a synonym dictionary per lang...
New
polvalente
We have released v0.13 of nx, exla and torchx, along with a recently released emlx v0.4. Nx This is where the bulk of the updates happen...
New
mudasobwa
After years of struggling I made StreamData dependency optional. Finitomata.ExUnit got testing primitives for Persistence. Full back co...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement