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:
High-level instrumentation helpers - trace_agent/3,trace_tool/3,
trace_llm/3,trace_prompt/3
Optional ReqLLM integration - Automatic instrumentation with token tracking
and streaming support
Pluggable backend architecture - Phoenix (OpenInference), Generic
OpenTelemetry, or custom handlers
Rich metadata tracking - Token usage, costs, tool calls, and more
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
Hex: agent_obs | Hex
Docs: agent_obs v0.1.0 — Documentation
GitHub:
Popular in Announcing
Hey folks!
AshEvents Release
We’ve just released the first version of AshEvents, an Event Sourcing tool for Ash Framework apps.
Check o...
New
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
Hello everyone! :waving_hand:
I’m excited to introduce my first Elixir library: YOLO, a library designed to make real-time object detect...
New
Greetings Elixir community!
Today, I’m thrilled to present you with resvg_nif, an open-source project that provides Elixir bindings for ...
New
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
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
Ever struggled with mocking external HTTP services in Elixir tests? Found yourself writing brittle mocks that don’t catch real-world enco...
New
LiveViewPortal is a small library that allows third-party sites to embed LiveView apps.
The library is distributed as an NPM package. On...
New
MDEx is a fast and extensible Markdown parser and formatter.
Fast
Leverage Rust to parse, manipulate and render documents using:
comra...
New
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
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
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
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
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
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...
New
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
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
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
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
by Lance Halvorsen
Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
New








