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
I’ve published the first version of my Makeup library. It’s a syntax highlighter for Elixir in the spirit of Pygments, Currently it highl...
New
Today I released a new dialyzer Mix task as the dialyzex package! At the time we started writing this task, the existing dialyzer integra...
New
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below.
Hi everyone,
We a...
New
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API.
Docs are at OpenaiEx User Guide — ope...
New
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention.
Assuming you have...
New
I created Kitto a framework for dashboards inspired by Dashing.
[demo]
The distributed characteristics of Elixir and the low memory foo...
New
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps:
bureaucrat - which contains a bunch ...
New
Earmark is a pure-Elixir Markdown converter.
It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
New
Hey everyone!
Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
New
I released Doggo, a collection of unstyled Phoenix components.
Features
Unstyled Phoenix components.
Storybook that can be added to...
New
Other popular topics
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New








