Topic guide

Elixir and the BEAM for AI systems

Every AI agent framework ships in Go or Python, and almost nobody asks why — or what it costs. The posts below make the unfashionable argument: the runtime agents actually want has existed since 1986, the language AI writes best is the one with the fewest ways to go wrong, and boring stacks ship faster than exciting ones.

Start with the concurrency-model post if you're evaluating stacks — it's the foundation the rest build on. The BEAM-for-agents post applies it to agent architectures, the Go post is the steelman for the mainstream choice, and the Ruby post is for when the right answer is the stack you already have. The back half is the same argument in production code: streaming tokens to a LiveView without paying for a stream nobody is watching, agent runs that survive a deploy, evals that don't burn tokens on every push, and the telemetry that tells you what all of it costs.

The reading order

  1. 1.

    Elixir's Concurrency Model Is the One You Actually Want

    The foundation: processes, supervision, and why the concurrency model other stacks fake with queues and retries is the default here.

    May 16, 2026 14 min read

  2. 2.

    Elixir's BEAM Is the Runtime AI Agents Want

    Agents are long-running, stateful, failure-prone processes — exactly the workload the BEAM was designed for four decades ago.

    May 31, 2026 12 min read

  3. 3.

    Why We'd Pick Elixir for an AI Startup Backend

    An AI backend is agents holding a session for seconds or for hours, token streams pushing model output to a live UI, six flaky tool calls per turn, and durable multi-step jobs — the property Python and Node concurrency are weakest at. The costs stated plainly: the model and ML layer is still Python's, the hiring pool is smaller, and mostly-stateless CRUD over a hosted model API buys you little.

    July 23, 2026 13 min read

  4. 4.

    What Elixir Gives a Coding Harness for Free

    José Valim's three mechanics for a coding harness, taken seriously: hot-code reload that keeps a session's state through a plugin swap, client/server as a byproduct of the actor model, and Node.connect/1 plus Node.spawn/3 splitting the brains (model + session) from the hands (sandbox + tools) — the shape Livebook's attached-node runtime already ships. The tax he names only in passing: distribution moves execution without deciding what that execution may do, so Docker or a microVM is still yours to build, plugin authors write TypeScript, and provider protocol churn reaches Python and TS first. Internal harness on a stack you already run, yes; general-market harness, the ecosystem tax compounds on every axis adoption depends on.

    August 15, 2026 8 min read

  5. 5.

    Why Every AI Agent Framework Is Written in Go (And What That Costs You)

    The steelman: why every agent framework picked Go, and the supervision, hot-code, and state-recovery costs hiding in that choice.

    May 16, 2026 12 min read

  6. 6.

    Elixir Is the Language AI Codes Best

    Pattern matching, immutability, and a small surface area — why LLMs generate better Elixir than Python or TypeScript.

    May 27, 2026 8 min read

  7. 7.

    TDD With Claude Code in Elixir: What Holds Up

    Three tests in this repo, three different answers to "is this safe concurrently" — and marking a new test async: true without checking is the ExUnit mistake an agent makes unprompted. The argument: mix precommit, compile --warnings-as-errors plus the full suite, is the instruction Claude actually follows, and the Oban idempotency test gets written before the job body, because an agent generating job code from a prompt has no way to know retries are in play.

    July 18, 2026 10 min read

  8. 8.

    Ruby Isn't Dead, It Got Boring — And Boring Is Why It Ships

    The counterweight: boring is a feature. If the team knows Rails, the right AI stack might be the one that ships this quarter.

    May 16, 2026 12 min read

  9. 9.

    What Together AI's $800M Round Says About Elixir

    Together AI's $800M Series C at an $8.3B post-money valuation, read off the Greenhouse listing instead of the press release: authentication flows including SSO and OAuth, organizations, projects, API keys, and role-based access controls, on Elixir/Phoenix services. Elixir sits at 2.7% of respondents in the 2025 Stack Overflow Developer Survey — raw adoption share answers the wrong question.

    July 23, 2026 7 min read

  10. 10.

    Build an AI Agent Loop in 50 Lines of Elixir

    The whole argument, executable: observe-decide-act in 50 lines with no framework — a GenServer doing what agent frameworks abstract.

    June 21, 2026 10 min read

  11. 11.

    Testing AI Agent Outputs in Elixir with ExUnit

    Two seams make the 50-line agent loop testable: thread opts down to Req.post/1 so a test can pass plug: {Req.Test, Agent.LLM}, and emit an [:agent, :tool_call] telemetry event so you can assert on tool-call sequences, not just the final string. Tribunal's faithfulness and hallucination checks cost a model call and tag themselves :eval, which test_helper.exs excludes by default — mix test --only eval runs them.

    July 20, 2026 13 min read

  12. 12.

    15 Elixir Libraries I Reach For in 2026

    The day-one Hex install list — what each library earns its place doing, and the ones that got dropped along the way.

    June 23, 2026 13 min read

  13. 13.

    RAG in Phoenix: Hand-Rolled pgvector or Arcana?

    You don't need a vector database — the Postgres you already run does RAG fine. The hand-rolled path, and when Arcana earns its place.

    June 18, 2026 9 min read

  14. 14.

    Streaming LLM Tokens in LiveView, the 2026 Way

    The naive version — accumulate each token into an assign and re-render — keeps paying the model after the user closes the tab, rebuilds an ever-growing binary on every token, and sits on half a sentence when OpenAI returns a 500 four tokens in. start_async/4 gives a real terminal event through handle_async/3, and Req's function-form :into drives the request inside the task so the upstream socket dies with it — into: :self is the trap that spawns a helper which outlives your task and keeps draining. Buffer 50ms or 20 tokens and flush one update: the rate the model emits tokens should not be the rate you re-render.

    July 14, 2026 15 min read

  15. 15.

    Oban as a Durable AI Agent Runtime in Elixir

    One Oban job per ReAct step, enqueued in the same Ecto.Multi transaction as the state write, so a deploy at step 23 resumes from an agent_runs row instead of dying with a GenServer's heap. {:snooze, seconds} for a rate limit, {:cancel, reason} for a 400 or 422 that will fail identically every time, and an idempotency key derived from run plus step so a retried charge doesn't double-bill.

    July 2, 2026 14 min read

  16. 16.

    Instrumenting LLM Calls in Phoenix with Telemetry

    ReqLLM already emits token counts, calculated cost, and request duration on every call, so the work is five lines of Telemetry.Metrics connecting an event that already exists to a dashboard Phoenix already ships. The hand-rolled :telemetry.span/3 version for raw Req/Finch, the tag_values step that pulls .id out of ReqLLM's LLMDB.Model struct before it reaches a label, and the two numbers worth alerting on: cost per day trending, p95 latency per provider.

    July 30, 2026 10 min read

  17. 17.

    Build an MCP Server in Phoenix With Hermes

    Hermes 0.14 in a Phoenix app: tools as components, one forward to the StreamableHTTP transport plug, and authentication in the server's init/2 — a Plug.Conn assign does not reach a Hermes tool. Every tool maps to a named function in one of your contexts, Billing.customers_over_limit/2, never the lazy single run_sql tool that hands the model your database connection and calls it flexible. Skip the protocol entirely if the only thing calling your app is a script you also wrote.

    July 9, 2026 13 min read

  18. 18.

    The Ruby to Elixir Migration That Cut Our Service Footprint From Ten to Six

    The production receipts: ten services to six at InsideTrack, the migration order that worked, and when not to migrate.

    February 9, 2026 9 min read

  19. 19.

    Wiring LiveView Uploads to Claude Vision

    max_file_size: 7_500_000 is derived, not round — Claude's base64 image cap is 10MB and encoding inflates raw bytes by roughly 4/3, so a 9.5MB JPEG passes a naive 10MB check and is rejected after the upload finishes. The gate no vendor doc writes for you is page count: a 6MB PDF can carry 80 pages against a 100-page ceiling when the context window is under 1M tokens, and each page costs 1,500 to 3,000 text tokens plus the image tokens of a rendered screenshot. The consume callback returns bytes, not meta.path — the temp file is gone by the time an async task reads it.

    August 20, 2026 13 min read

  20. 20.

    Structured LLM Output in Elixir: Which Library, When

    Four options scored against each other, which the HexDocs-and-GitHub SERP never does. InstructorEx has the name and 781 stars and a repo unpushed since 2025-06-07; InstructorLite is the fork actually shipping. The finding came from reading source instead of a README: ReqLLM's generate_object does not re-prompt the model on a validation failure the way both Instructor libraries do — it coerces locally and, when that fails, hands back the malformed data as a success.

    August 17, 2026 12 min read

  21. 21.

    Metering LLM Usage Per Customer in Phoenix

    A dashboard tolerates an undercount; an invoice line is a claim you make to a paying customer. Cost lands in integer micro-dollars — Sonnet 4.6 at $3 and $15 per million tokens is exactly 3 and 15 micros per token — and rounds to cents once, at invoice time: 1,055,250 micros is 105.525 cents, so 106. Append-only, with a unique index on request_id so a retried job can't double-bill. tenant_id is a required argument on the wrapper, because there is no honest way to reconstruct whose bill a call belongs to afterward.

    August 13, 2026 13 min read

  22. 22.

    Phoenix Secrets: runtime.exs, Fly.io, and LLM Keys

    config.exs freezes whatever the build machine happened to have; runtime.exs reads the environment the process is actually running in. fetch_env!/1 over get_env/2 with a fallback, so a missing key raises at boot and Fly stops the rollout rather than surfacing as a 401 a customer finds first. Dotenvy never calls System.put_env, so a dev .env can't bleed into the production read path. And an LLM key is a bearer credential against a metered bill — GitGuardian has AI-service secrets up 81% year over year, with sk-ant- and sk-proj- now as fingerprintable as AKIA.

    August 10, 2026 10 min read

  23. 23.

    10 Ecto Query Patterns for N+1 and Beyond

    Separate queries for has_many, a join for belongs_to — a row-count argument, not a style preference. Join a post to its ten comments and Postgres repeats the post's columns ten times; join it to its author and nothing multiplies. Most of the N+1s worth unwinding were never missing preloads at all; they were a has_many joined the way you'd correctly join a belongs_to. The other nine patterns are the exceptions, each with its own trigger.

    July 28, 2026 11 min read

  24. 24.

    Isolating Parallel Claude Code Agents in Phoenix

    A worktree isolates the file tree and the branch. It does nothing about the port, the database, or the asset watchers, which is exactly where a Phoenix app breaks. Give each worktree its own database named after the slot rather than the branch — Ecto's Sandbox fences concurrent tests inside one node and has no opinion at all about two mix phx.server processes writing the same table. Practical ceiling is four or five, and coupled work is still lazier run one at a time.

    July 27, 2026 10 min read

  25. 25.

    12 Phoenix LiveView Patterns for Production

    Twelve named failure modes verified against LiveView 1.1, and eleven are one insight in different clothes: the dead render and the connected socket are two different worlds, and the client side of that boundary is hostile. mount runs twice, so an unguarded query bills the database twice and a PubSub subscribe in the dead pass leaks. And mount authorization gates viewing the page and nothing else — a client can push any event with any payload down the socket, ids belonging to other tenants included.

    July 21, 2026 15 min read

Other topic guides

  • AI engineering What production AI engineering actually looks like in 2026 — the autonomy ladder for agents, the workflow shift, telemetry, and team sizing.
  • Security for startups A guided reading order for startup security — what to read first on SOC 2 as a revenue tool, vCISO hiring, and securing AI-native products.
  • Engineering leadership Engineering leadership at startup scale — hiring from one engineer to fifteen, rituals that work at small teams, the staff-engineer interview loop.

Or browse differently