KristerV

KristerV

Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty difficult. The LLM models themselves are not actually very intelligent it seems, the tooling is crucial to get a useful agent out of these text generators.

I decided to write down my findings and experiences so people don’t have to reinvent the wheel, but at the same time I’m hoping someone will tell me that I’m doing it all wrong and give me a recipe for success.

Ultimately a friend says they use the Claude Agent SDK and get their agents running without too much effort and with good results. That’s what I want. But all the official tooling is for the JS ecosystem, obviously. Anyway, here’s the current state.

Features an agent needs to be useful

  1. Plan-Act-Verify Loop: Explicit verification step after actions.
  2. State Machine Persistence: Durable storage of agent “thought” and “status” (Checkpoints).
  3. Context Compaction: Auto-summarizing history to prevent token bloat/model drift.
  4. Memory Layering: Separating ephemeral “Working Memory” from “Long-term Knowledge.”
  5. Human-in-the-Loop (HITL): Breakpoints for manual approval on sensitive actions.
  6. Model agnostic: Switching from one LLM model to another shouldn’t cause problems/rewrites.

This is not an exhaustive list for agents, just what I know is needed atm.

Industry tools

Here’s the tooling non-Elixir environments have

  1. Vercel AI SDK (Typescript)
  2. LangGraph (JS/Python).
  3. PydanticAI (Python)
  4. Claude Agent SDK (Python/TS)
  5. OpenAI Agents SDK (Python/TS)

Elixir tools

  1. LangChain (Elixir): An Elixir-native implementation of the LangChain framework. It focuses on “Chaining” processes and providing modular components for prompt management and model integration.
  2. Jido: OTP-native state-machine framework for autonomous agents (Action/Signal/Runner). This is the “power-user” choice for complex, long-running agent logic.
  3. Legion: A dedicated harness library specifically for building agentic loops and tool execution.
  4. AshAi / AshBaml: Crucial bridges for turning your existing Ash Resources and Actions into LLM-accessible tools.
  5. Instructor Ex: The go-to for type-safe data extraction and validation using Ecto schemas.
  6. ReqLLM: An LLM-specific client for the Req library.
  7. LLMAgent: A signal-based library designed for managing conversation flows and tool handlers.
  8. Oban: Essential for job persistence, concurrency control, and “Resume from failure” logic.
  9. Elixir AI SDK: A community port that brings the Vercel AI SDK’s maxSteps and streaming patterns to Elixir.
  10. edit: just found Whisperer, looks like a good first layer of such a system.

My experience

I started with langchain, but switching models breaks the app code, which makes the lib kind of pointless. And they don’t really accept PR’s, but that’s understandable tbh. I switched to OpenRouter.ai and that works great with only a 5% addition to cost of the LLM models.

I currently have built my agents on Oban. A custom loop of messages, context pruning, planning etc. But it’s brittle. Now I have to rebuild my architecture to be more deterministic (because the models just aren’t very smart on their own).

The libraries look to me like each does one part of the puzzle or if it tries to do it all it’s just not very deep. And since docs are not deep either it’s one of those things where you spend a week trying them all out and then realize none of them do what you need. Out of all of them Legion seems to be the most all inclusive option with orchestrators and an agent loop. But no plan → exec → verify it seems. Which is kind of core, so don’t really want to jump into it.

Anyway, these are just my thoughts. I’m probably misunderstanding a bunch.

My question

My point is not to complain or point at missing pieces. Rather I have a feeling I’m missing the big picture. So I ask - how do you build agents? What libraries, techniques or approaches do you use?

Showing Posts 1 to 10

typesend

typesend

See also Sagents:

https://github.com/sagents-ai/sagents

(Launched very recently.)

typesend

typesend

Dmk

Dmk

I just use GenServers - no libraries. Each agent is a GenServer. I have 1 orchestrator agent which has a list of all of the subagents. All of them have tools available.

I did try LangChain… but honestly more of a learning curve than just doing your own thing. Jido I looked at but never tried… not sure of the benefits (for my use case at least).

I would strongly suggest looking at GenServers and not using Oban for this.

tfwright

tfwright

How do you handle persistence through app restarts?

Dmk

Dmk

Persistence of what?

I presume you mean chat history? I save to the DB.

tfwright

tfwright

I tend to agree with OPs reasons for using Oban.

Oban: Essential for job persistence, concurrency control, and “Resume from failure” logic.

In fact, I have found myself using Oban as my state machine library of choice since its states and arg persistence and retry handling cover pretty much all my uses cases. Before I found myself adding a “status” enum with only minor variation in values and repetitive transition logic to various contexts/schemas. Bringing in a new dep just to handle that kind of thing seemed unnecessary, but as I went to abstract it myself I realized I was recreating a bunch of APIs I already had at my disposal in Oban. So I started to lean more on it and most of that stuff just became worker config, leaving only the need to enqueue jobs with the appropriate args. Logic has much better SoC because the schemas now only express states that are actually specifically meaningful to the domain, and all the generic “error” “pending“ etc stuff is hidden away and protected with much better guarantees than I ever managed to maintain. And that’s before using any of the Pro features like workflows. So it’s hard for me to imagine the downside to using Oban for something like this.

Dmk

Dmk

Are you saying use Oban to build out AI agents?

tfwright

tfwright

I am in the same boat as OP, actually likely quite a bit less experienced. I have only just started building out my first LLM backed features and given what I said above Oban is a key component so far. My experience with using Oban in FSMs has been excellent, and given the implicit need for FSMs in many “agentic” workflows, it seems a natural fit to me. But I’m open to arguments to the contrary.

dimitarvp

dimitarvp

That, or maybe GitHub - nshkrdotcom/flowstone: Asset-first data orchestration for Elixir/BEAM. Dagster-inspired with OTP fault tolerance, LiveView dashboard, lineage tracking, checkpoint gates, and distributed execution via Oban. · GitHub.

Both are excellent to persist and enrich a “god”-like object as a mission is progressing. Granted it would be easier and quicker with Oban Pro but not all companies agree with a subscription for that.

I found have the free Oban to be amazing at orchestration. Sure it’s a bit more manual but as @tfwright says: a lot of stuff is already taken care of for you so why would you reinvent it? The fact that something does not give you 100% of what you need (but say, 60% - 80%) does not mean it should be ignored for the task.

KristerV

KristerV OP

I’ve used Genservers for a lot of things and 99% of the cases end up being jobs. An agent loop is ultimately a job. When it’s done it’s task - job is done. So Oban is a natural fit.

Okay, this is the most fully featured thing I’ve seen so far. Need to investigate further, thanks.

Where Next? Top

Trending in AI / LLMs Top

AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
With advancements in AI gathering pace and set to increasingly accelerate, perhaps it’s worth having an annual thread on the topic - feel...
New
dmitriid
What A larger rant at in this post. Code at github: GitHub - dmitriid/llamex: Credo Plugin that detects issues that LLM-assisted Elixir r...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews