lostbean

lostbean

AgentObs - LLM Agent Observability for Elixir

AgentObs - LLM Agent Observability for Elixir

I’m excited to share AgentObs, a new library for instrumenting LLM agentic
applications in Elixir with rich observability!

What is AgentObs?

AgentObs provides a simple, idiomatic interface for tracking agent loops, tool
calls, LLM requests, and prompts in your Elixir applications. It uses native
:telemetry events and translates them to OpenTelemetry spans with
OpenInference semantic conventions.

Key Features:

  • :bullseye: High-level instrumentation helpers - trace_agent/3, trace_tool/3,
    trace_llm/3, trace_prompt/3
  • :robot: Optional ReqLLM integration - Automatic instrumentation with token tracking
    and streaming support
  • :electric_plug: Pluggable backend architecture - Phoenix (OpenInference), Generic
    OpenTelemetry, or custom handlers
  • :bar_chart: Rich metadata tracking - Token usage, costs, tool calls, and more
  • :rocket: Built on OTP - Supervised handlers with fault tolerance

Quick Example

defmodule MyApp.WeatherAgent do
  def get_forecast(city) do
    AgentObs.trace_agent("weather_forecast", %{input: "What's the weather in #{city}?"}, fn ->
      # Call LLM to determine tool to use
      {:ok, _response, _metadata} =
        AgentObs.trace_llm("gpt-4o", %{
          input_messages: [%{role: "user", content: "Get weather for #{city}"}]
        }, fn ->
          response = call_openai(...)
          {:ok, response, %{
            output_messages: [%{role: "assistant", content: response}],
            tokens: %{prompt: 50, completion: 25, total: 75}
          }}
        end)

      # Execute the tool
      {:ok, weather_data} =
        AgentObs.trace_tool("get_weather_api", %{arguments: %{city: city}}, fn ->
          {:ok, %{temp: 72, condition: "sunny"}}
        end)

      {:ok, "The weather in #{city} is #{weather_data.condition}", %{
        tools_used: ["get_weather_api"]
      }}
    end)
  end
end

ReqLLM Integration

For apps using ReqLLM, AgentObs provides helpers
that automatically extract tokens, tool calls, and more:

# Non-streaming
{:ok, response} =
  AgentObs.ReqLLM.trace_generate_text(
    "anthropic:claude-3-5-sonnet",
    [%{role: "user", content: "Hello!"}]
  )

# Streaming
{:ok, stream_response} =
  AgentObs.ReqLLM.trace_stream_text(
    "anthropic:claude-3-5-sonnet",
    [%{role: "user", content: "Tell me a story"}]
  )

Visualization

Use with Arize Phoenix to get beautiful trace visualization with chat messages,
token usage, and nested spans:

Links

Where Next?

Popular in Announcing Top

zachdaniel
Hey folks! AshEvents Release We’ve just released the first version of AshEvents, an Event Sourcing tool for Ash Framework apps. Check o...
New
Schultzer
Hey there, I wrote this low-level library recently, its goal is simply to lower the barrier between Elixir and SQL, and it does that by p...
New
alvises
Hello everyone! :waving_hand: I’m excited to introduce my first Elixir library: YOLO, a library designed to make real-time object detect...
New
MRdotB
Greetings Elixir community! Today, I’m thrilled to present you with resvg_nif, an open-source project that provides Elixir bindings for ...
New
kasvith
Hello Everyone, I was working with some HTML-to-Markdown libraries and ran into a few issues when converting a complex markup file to Ma...
New
Zurga
Subscribe to events emitted by EctoWatch, and cache the changed row. Use the sync/3 function to update an in-memory row or list of rows u...
New
johantell
Ever struggled with mocking external HTTP services in Elixir tests? Found yourself writing brittle mocks that don’t catch real-world enco...
New
victor23k
LiveViewPortal is a small library that allows third-party sites to embed LiveView apps. The library is distributed as an NPM package. On...
New
leandrocp
MDEx is a fast and extensible Markdown parser and formatter. Fast Leverage Rust to parse, manipulate and render documents using: comra...
New
jallum
Hey folks :waving_hand: I’ve been building a distributed key-value store in Elixir/OTP called Bedrock. It implements FoundationDB’s arch...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement