Langfuse alerts and rules on the traces you already collect
Langfuse alerts fire when a metric crosses a threshold. Upload the same traces to Amiril to find unusual runs and issues, post them to Slack and block bad tool calls.
Langfuse alerts fire when a metric crosses a threshold. Upload the same traces to Amiril to find unusual runs and issues, post them to Slack and block bad tool calls.
Langfuse alerts watch a number. You pick a metric from your traces, such as p95 latency, cost or the average of an evaluator's score, give it a threshold and a window, and Langfuse posts to Slack, PagerDuty, a webhook or GitHub Actions when the number crosses the line. An alert reads an aggregate over a window, so one run that went wrong at normal speed and normal cost moves nothing it measures. Amiril reads the same traces, starting from a Langfuse export you upload, and ranks every run by how unusual it was for its own agent. Runs that share a problem become an issue. Issues at High or above, such as those the grounding check raises, post to Slack as they form, and a rule drafted from an issue stops the tool call before it runs.
Langfuse shipped alerts in June 2026. You create one under Alerts in a project, as its alerts page shows, and choose what it measures. The data source is observations, scores of one of three types, or billable units. The metric is an aggregation and a measure, such as avg latency, count or p95 cost, narrowed by filters on model name, tags, user or environment. Then you give it a threshold, optionally a warning threshold too, and a window of one hour to seven days.
When the severity changes, Langfuse hands the event to the automations you linked to the alert. There are four kinds: a Slack message, a PagerDuty alert, an HMAC-signed webhook and a GitHub Actions workflow_dispatch. On Langfuse Cloud the Hobby plan stops at two alerts per organization, enough for one latency ceiling and one cost ceiling, and self-hosted v4 has no cap.
The average of a boolean score is the share of true values, so an LLM-as-a-judge evaluator that marks replies breaking a policy turns into a violation rate you can put a threshold on. A single false score triggers nothing by itself, since no webhook fires per score and alerts evaluate only aggregates over a window. Langfuse monitoring for an agent can then pair a p95 latency ceiling per model with a ceiling on that violation rate.
Take a support agent with two tools, lookup_order and issue_refund. On nearly every run it looks the order up, checks the total and refunds. One afternoon a customer types an order number with two digits swapped, and the model calls issue_refund on it straight away, on an order that belongs to someone else.
The run is one tool call and one model call shorter than usual, so it finishes faster and cheaper than the agent's median. The judge scoring replies for helpfulness rates it well, since the reply was polite and sure of itself. A judge written for exactly this failure would mark the run false, and in a window of 400 scored runs that moves the rate Langfuse alerts watch by a quarter of a point.
Amiril reads Langfuse observations as JSONL, one object per line. For a quick look, the export button on Langfuse's observations table gives you that file. For a few months of history, page through Langfuse's v2 observations API. This script pulls everything since 1 September into one gzipped file:
#!/usr/bin/env bash
set -euo pipefail
from="2026-09-01T00:00:00Z"
to=$(date -u +%Y-%m-%dT%H:%M:%SZ)
cursor=""
: > observations.jsonl
while :; do
page=$(curl -sfG "$LANGFUSE_HOST/api/public/v2/observations" \
-u "$LANGFUSE_PUBLIC_KEY:$LANGFUSE_SECRET_KEY" \
--data-urlencode "fields=core,basic,io,time,model,usage,trace_context,metadata" \
--data-urlencode "fromStartTime=$from" \
--data-urlencode "toStartTime=$to" \
--data-urlencode "limit=100" \
${cursor:+--data-urlencode "cursor=$cursor"})
jq -c '.data[]' <<<"$page" >> observations.jsonl
cursor=$(jq -r '.meta.cursor // empty' <<<"$page")
[ -n "$cursor" ] || break
done
gzip -f observations.jsonlLeave out fields and the inputs and outputs come back empty, and with them the tool arguments. Langfuse asks you to bound every request by start time, and a page can come back empty while there are more after it, which is why the loop runs until the cursor stops and not until data is empty.
In Amiril, switch to the environment the runs belong to, open Data and drop observations.jsonl.gz on the page. Files up to 2 GB work. The upload gets a row under History that moves through Reading and Scoring to Ready. An upload brings in older runs too, so a quarter of history gives each agent a long record of what it normally does from the first day. Each Langfuse trace becomes a run, filed under the agent its trace name gives. Timestamps with no timezone are read as UTC, and Change timezone on the upload's row reads them again in another zone.
Every run gets a rarity, measured in bits that come only from the same agent's earlier runs. It shows as a standing against every run in the environment over the last 30 days, such as "Top 1%". The refund run would carry a rarity factor like this one, filed under Broken pattern:
lookup_order was not called, which happened in 3 of 2,140 other runs
Your review budget, how many runs you want to review each week or what share of them, sets a bar for each agent, and a run whose rarity reaches it waits on the Anomalies page. When three runs share their strongest rarity factor, or you confirm one, they form an issue for the support agent on the Issues page. Amiril's investigator reads a sample of the issue's runs with an AI model and writes up what they share under What is happening.
Checks also raise issues, working from what the run said. The grounding check, for one, catches a value the agent stated that no tool result or earlier message contains, such as a refund amount the agent made up, and its issues start at Critical. A check needs only one run to start an issue.
After the upload, send new runs as they happen. Langfuse's Python SDK v3 and later is built on OpenTelemetry and, by default, attaches its span processor to the global tracer provider. So one provider can feed both. Here is Amiril's tracing setup for a LangGraph agent, with the Langfuse client started on that same provider:
from langfuse import get_client from openinference.instrumentation.langchain import LangChainInstrumentor from opentelemetry import trace from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor provider = TracerProvider() provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter())) trace.set_tracer_provider(provider) langfuse = get_client() LangChainInstrumentor().instrument(tracer_provider=provider)
OTLPSpanExporter() reads Amiril's endpoint and API key from the standard OTEL_EXPORTER_OTLP_TRACES_* variables, and the Langfuse client reads its own LANGFUSE_* keys. Langfuse's processor exports spans with gen_ai.* attributes and spans from known LLM instrumentations, so the OpenInference spans reach both. If your agent passes Langfuse's CallbackHandler today, these OpenInference spans replace it. Give the graph the name your uploaded traces carry, so live and uploaded runs land on one agent. Other frameworks take their own OpenInference instrumentor in place of LangChainInstrumentor.
With live runs arriving, connect Slack under Settings, Alerts, and pick a channel for the environment. A new issue at High or above posts at once, and a digest arrives at 08:00 UTC on days when an open issue came back, grew or is rising. The message names the agent and the issue:
support has a new issue. Stated a refund amount no tool result contains. Severity Critical Runs 2 Environment production [Open issue]
Each channel has its own switches, so one can take the digest while another takes only new issues.
The nearest thing to Langfuse rules is an evaluator, which scores observations after they happened. An Amiril rule runs in the agent's process, before the tool, and can refuse the call. For the refund issue, its page carries a rule suggestion with the rule drafted and a count of the issue's own runs it would have stopped, such as "Would have blocked 3 of 3 runs". Create rule opens it in the editor:
@id("lookup-before-refund")
@sentence("Order {order_id} was not looked up earlier in this run")
block (
agent == "support",
tool == "issue_refund"
)
unless {
lookup_order{ args.order_id == call.args.order_id }
};The rule blocks a refund unless the same run already called lookup_order with the same order id. Once it's saved, Test on past calls replays it over the tool calls already stored, uploaded ones included, and lists each call it would have fired on. Published, it starts in Shadow, where it records what it would have done and lets every call through. When you trust it, switch it to Enforce on its page.
The Amiril SDK enforces it in the agent. Without a framework, it wraps the tool functions:
import amiril
from amiril import plain
amiril.init()
agent = plain.Agent("support")
@agent.tool
def lookup_order(order_id: str) -> dict:
return orders.get(order_id)
@agent.tool
def issue_refund(order_id: str, amount: float) -> dict:
return payments.refund(order_id, amount)Give the SDK agent the trace name Langfuse shows for it, so the traces, the issue and the rule all point at one agent. Each piece of work goes inside with agent.run(session_id=...) as run:, with run.turn() at each model reply. LangGraph, Google ADK and LiveKit have their own adapters. A refund for an order nobody looked up never reaches payments.refund, and the model gets this back in its place:
The call to issue_refund was not performed. Rule lookup-before-refund blocked it: Order A-1042 was not looked up earlier in this run (lookup_order.exists false). Do not retry this call with different arguments or achieve the same outcome another way; tell the user it was not performed.
The SDK checks against a copy of your published rules held in the agent's memory, and fetches changes about once a minute, so an edited rule reaches agents that are already running. If Amiril can't be reached, it keeps enforcing the last rules it had, and a copy on disk survives a restart.
For what Amiril adds on top of the traces Langfuse already holds, see Langfuse and Amiril. Upload the file the script above writes, on any plan.