Exploring AI Failures
PostHogOfficialPublished by PostHog
- Skill
- Research and analysis
- Data and AI
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Most AI application failures are silent, occurring without code exceptions or HTTP errors. This skill provides a systematic, bottom-up approach to discovering these issues by reading real production traces. Rather than relying solely on automated metrics, you will scope your analysis to specific use cases, select traces based on signals like outliers or error spikes, and manually review them to build a ranked taxonomy of failure modes. This process transforms raw trace data into actionable insights, enabling you to prioritize fixes, improve prompts, or develop targeted online evaluations.
What it does
- Scopes analysis to specific AI use cases or feature sets.
- Identifies candidate traces using metrics, error flags, or stratified sampling.
- Facilitates deep-dive reading of individual AI traces to uncover silent failures.
- Groups observed failures into a ranked, named taxonomy of failure modes.
- Generates deep links to specific traces for verification and stakeholder review.
- Provides a foundation for creating automated online evaluations for identified issues.
When to use it
- When you need to understand why an AI feature is producing poor quality results.
- When you want to move beyond simple error counts to address silent failures like hallucinations.
- When you need to prioritize development work based on the most frequent failure patterns.
- When you are preparing to implement automated evaluations for specific failure modes.
Advantages
- Focuses on the most impactful failures rather than just loud code exceptions.
- Uses a bottom-up approach that discovers real-world patterns instead of relying on pre-set metrics.
- Produces a clear, ranked list of issues that are ready for remediation.
- Connects analysis directly to actionable next steps like prompt engineering or evaluation authoring.
Usage examples
- “Why are the responses in my support agent bad?”
- The agent will help you scope the support agent's traffic, guide you to select a sample of traces, and assist in identifying common failure modes like policy hallucinations.
- “Surface the common failure modes for my summarizer tool.”
- The agent will analyze your summarizer's traces to find patterns such as dropped key points or truncation, presenting them as a ranked list with linked examples.
- “What should I fix next in my AI pipeline?”
- The agent will review recent failure patterns found in your traces and recommend the most frequent or critical mode to address, offering to help set up an evaluation for it.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/posthog/exploring-ai-failures/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip exploring-ai-failures.zip -d .agents/skills
Documentation by PostHog
Exploring AI failures
The highest-value thing you can do with production AI traffic is look at where it fails and name the patterns. The catch: most failures are silent. The model returns a clean response — HTTP 200, no exception — that is wrong, off-topic, ignores an instruction, or misuses a tool. Those never raise an error, and they're usually the failures worth caring about.
So this skill is about finding failures (loud and silent), reading them, and grouping them into a
ranked set of failure modes you can act on: fix a prompt, file a bug, prioritize work, or turn the
top mode into an automatic eval (creating-online-evaluations).
Everything below serves one irreducible activity: reading real traces. The queries only tell you which traces to open — they are never the answer. If you report a list of problems without having opened traces, you've described the loud minority (the things that throw errors) and missed the job.
This is bottom-up: the failure modes emerge from real traces, not from a list of generic metrics decided
in advance. For reading a single trace in depth, lean on exploring-llm-traces; for emergent grouping at
high volume, exploring-llm-clusters.
Tools
| Tool | Purpose |
|---|---|
posthog:query-llm-traces-list | List candidate traces — filter by error, sort by a metric, scope by type |
posthog:query-llm-trace | Read a trace in full to see what actually went wrong |
posthog:execute-sql | Find metric outliers, discover the trace taxonomy, count failure modes |
posthog:llma-evaluation-list | Find existing evals whose failures might reveal a new mode |
posthog:generate-app-url | Build a region- and project-qualified deep link to a trace or list |
Detailed queries for each strategy below are in
references/finding-traces.md. That file also explains the events vs
ai_events split: heavy content like $ai_input / $ai_output_choices is not on events. For the
full $ai_* event schema, load the exploring-llm-traces skill.
Work with the user
Collaborate on scope and priorities — not on whether to do the work. Narrow with the user up front: which feature or use case? have they already seen something bad? is there a signal to follow (a thumbs-down, a ticket, a metric that looks off)? Once it's scoped, go read traces and come back with coded failure modes — don't stop to ask permission before the reading; that reading is the core activity, not an optional follow-up to offer. When the user doesn't know what to look for, drive the loop below and explain the reasoning as you go; keep the teaching opt-in.
Step 1 — Scope to one use case
Apps have a taxonomy of trace types, and each fails differently — a support chat hallucinates policy, a
summarizer drops key points, an agent loops or misuses a tool. Evaluating or analyzing them together
averages the signal away. Pick one, then find its filter (a $ai_trace_id prefix, a feature
property, a model). If the user isn't sure how their traffic splits, discover the taxonomy first (query
in references/finding-traces.md).
Step 2 — Pick which traces to read
These are ways to select which traces to open — not answers in themselves. The queryable ones (error counts, metric aggregates) tell you where to look; they are never the output. Choose by the context and signals you have, and combine them:
Code errors (
$ai_is_error) — the cheapest sweep and the least representative signal: it only catches exceptions and API failures, not the silent quality failures that matter most. Use it to grab a few traces to read, not as a tally of "the problems." Slightly more useful for structured-output or tool-calling pipelines, where some failures do surface as parse/schema errors.Metric outliers — sort by output/input tokens, message length, cost, or latency and open the extremes. Runaway length, truncation, context bloat, and loops cluster at the tails.
One trace-type slice — narrow to a single kind of request so the traces you read share a taxonomy.
Stratified sample — when you have no specific signal (the common case), pull a mixed batch across slices and outcomes and read it. This is the default, not the fallback.
Existing-eval spikes — when evals already run, a jump in an eval's failures points you at traces to read (
llma-evaluation-list+execute-sqlover the$ai_evaluationevents).Clustering — at high volume, let groupings emerge to pick representative traces to read; see
exploring-llm-clusters.
The trap. It's tempting to
GROUP BYerror messages, produce a ranked table, and stop. That table is the loud minority — failures that raise an exception. The failures that matter for most AI products complete with HTTP 200 and only appear when a human reads the trace. A ranking built from error or metric counts you never opened is not the deliverable — it's a pointer to what to read next. If a query for silent failures comes back empty or awkward, that's a signal to read traces, not to give up and report the loud ones.
Step 3 — Read a batch (this is the job)
Open and actually read the traces you selected — plan on roughly 20–30 for a use case. Read each one with
query-llm-trace, whose one required argument is traceId; the value to pass is the trace's id from
the query-llm-traces-list result. This step is not optional, and nothing substitutes for it. You
cannot find silent failures with GROUP BY or by grepping outputs for "refusal" / "sorry" language,
because you don't yet know the patterns to search for — reading is how you discover them. A clever SQL
proxy that returns nothing is not evidence the failures aren't there; it means you have to read.
For each trace, note in plain language what went wrong — and jot down the trace's earliest-event timestamp
alongside the note (it's right there in the trace you just read, and in query-llm-traces-list's
createdAt). That timestamp and the trace ID is all you need to build a resolvable deep link in Step 4,
so capturing it now saves a second round-trip later.
When a trace fails in a chain, record the first thing that broke — the root failure usually causes the downstream symptoms, and fixing it clears them. Group the notes into a few named failure modes ("ignores the date filter", "invents a policy", "drops the second question"); a later pass can help cluster your notes, but review the groupings yourself. Keep reading until new traces stop turning up new modes (tens of traces, not thousands — stop when it goes quiet).
Step 4 — Rank, link, and hand back to the user
Rank the modes you found by reading, roughly by how often they showed up in your sample — a handful usually dominate. Present a short, ranked list of named failure modes. For each mode, include one or two example trace deep links on your own — don't wait to be asked, and don't make the user request them.
You read these traces, but you can misread one — a trace that looks like a hallucination may be correct in
context, and some of what you flag will be you misunderstanding the trace, not a real failure. So don't
present the list as settled fact. Give the user a couple of linked examples per mode, ask them to open the
links, then ask which mode they want to focus on next. Once they pick one, offer to catch it on new traffic
with an online evaluation (creating-online-evaluations).
(A list assembled from error messages or metric counts you never read is the loud subset, not this — go back to Step 3.)
When there's little to look at
If the use case is new or low-volume and you can't find enough failures: widen the time window or loosen the slice first; then stress-test with inputs that deliberately probe the constraints you care about (edge cases, long or ambiguous inputs, adversarial phrasing); or generate a small synthetic set across the dimensions that matter (request type × user scenario), run it through the system, and read those traces. Treat synthetic results as a bootstrap, not ground truth — they're unreliable for high-stakes or niche domains.
Constructing UI links
query-llm-trace returns a _posthogUrl for the trace it read, so hand that one back instead of composing
your own. Build a link yourself only for a trace you have an id for but haven't opened, and then only with
posthog:generate-app-url — never hand-write the host or the /project/<id>/ prefix. The url must be a
canonical catalog template; pass concrete ids via params, never inline them into the path.
Traces list:
generate-app-url {url: "/ai-observability/traces"}(then filter to your use case)Single trace:
generate-app-url {url: "/ai-observability/traces/{id}", params: {id: "<trace_id>"}}
No trace link carries a timestamp, so append ?timestamp=<url_encoded_timestamp> to whichever URL you hand
back — the trace page reads it to resolve older traces, and neither tool can express it.
Generated links resolve to the correct region host and project prefix (e.g.
https://us.posthog.com/project/<id>/ai-observability/traces/<trace_id>), so a user not already on the
target project still lands in the right place.
Tips
Reading is the job, not the last step. Aggregates, error counts, and scores are clues for which traces to open — never a substitute. Read a first batch before reporting anything, and don't ask permission to do it.
Don't over-index on errors.
$ai_is_erroris the loudest but least interesting signal; the failures worth your time usually complete without one.The finding strategies are a menu for picking traces to read, not a pipeline and not the answer. Pick by context, combine freely, and don't force an order.
One use case at a time. Different trace types have different failure taxonomies — mixing them blurs the result.
Frequency over completeness. The goal is the modes that happen most, not every conceivable failure.
The output is a ranked list of named failure modes from traces you read — that artifact is what makes the next step (fix, prioritize, or eval) obvious.
Hand back linked examples, then let the user steer. Don't stop at a categorical table. Give one or two resolvable trace links per mode unprompted, ask the user to eyeball a couple.
Related skills
creating-online-evaluations— turn a ranked failure mode into a continuously-running evalexploring-llm-clusters— compare behavior across clusters instead of reading traces one by oneexploring-llm-traces— the trace-reading mechanics this skill leans on
Files
- ATTRIBUTION.mdAdded by AutoGineer861 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md11.6 KiB
- references/finding-traces.md5.9 KiB
references/finding-traces.md
Finding failing traces — queries
Concrete queries for each strategy in Step 2. Property names ($ai_is_error, $ai_input_tokens, …) are
the standard AI event properties; confirm the exact ones for this project with read-data-schema.
Contents
Where heavy content lives:
eventsvsai_eventsDiscover the trace taxonomy
Code errors
Metric outliers
Manual review of a stratified batch
Existing-eval spikes
Counting failure modes
Where heavy content lives: events vs ai_events
The events table keeps only lightweight metadata: token counts, costs, model, provider,
$ai_trace_id, latency, and error flags. All queries below use it. The heavy content is not on
events. It lives as native columns on a separate table, posthog.ai_events:
| Heavy content | events property | ai_events column |
|---|---|---|
| Input messages | $ai_input | input |
| Output | $ai_output | output |
| Output choices | $ai_output_choices | output_choices |
| Input state | $ai_input_state | input_state |
| Output state | $ai_output_state | output_state |
| Tools | $ai_tools | tools |
query-llm-trace and query-llm-traces-list read posthog.ai_events for you, so use them to read
traces. Use SQL on posthog.ai_events only for batch analysis. trace_id is its access path, not
timestamp, so filter events first to get trace IDs, then fetch the content by trace_id:
WITH matching_traces AS (
SELECT DISTINCT properties.$ai_trace_id AS trace_id
FROM events
WHERE event = '$ai_generation' AND timestamp >= now() - INTERVAL 7 DAY
)
SELECT a.trace_id, a.span_id, a.model, a.input, a.output_choices
FROM posthog.ai_events AS a
WHERE a.trace_id IN (SELECT trace_id FROM matching_traces)
ORDER BY a.trace_id, a.timestampposthog.ai_events drops rows after the retention period (30 days by default), so older traces have
no content.
Discover the trace taxonomy
When the user isn't sure how their traffic splits, find the use cases before scoping to one:
-- By trace-id prefix convention (many apps namespace trace ids like "support:", "summarize:")
SELECT splitByChar(':', coalesce(properties.$ai_trace_id, ''))[1] AS kind, count() AS n
FROM events
WHERE event = '$ai_generation' AND timestamp >= now() - INTERVAL 7 DAY
GROUP BY kind ORDER BY n DESCOr group by whatever feature property the app sets (ai_product, agent_mode, a custom tag). Then scope
every query below to one slice.
Code errors
The cheap first sweep. Group the messages to see the error classes:
SELECT properties.$ai_error AS error, count() AS n
FROM events
WHERE event = '$ai_generation' AND properties.$ai_is_error = 'true'
AND timestamp >= now() - INTERVAL 7 DAY
GROUP BY error ORDER BY n DESCRemember this only catches exceptions/API failures. A trace can succeed (no $ai_is_error) and still be
wrong — those silent failures need the other strategies.
Metric outliers
Anomalies cluster around failures. Sort by a metric and read both extremes:
SELECT properties.$ai_trace_id AS trace_id,
properties.$ai_input_tokens AS in_tok,
properties.$ai_output_tokens AS out_tok,
properties.$ai_latency AS latency,
properties.$ai_total_cost_usd AS cost
FROM events
WHERE event = '$ai_generation' AND timestamp >= now() - INTERVAL 7 DAY
ORDER BY out_tok DESC -- also try in_tok, latency, cost; and ASC for truncation / empty outputs
LIMIT 25What the extremes tend to mean: huge output = runaway/repetition; tiny output = truncation or refusal;
huge input = context bloat or a stuffed prompt; high latency/cost = inefficiency or a loop. Open the
interesting ones with query-llm-trace.
Manual review of a stratified batch
Pull a mixed batch (slices and outcomes, not all errors) and read each candidate end to end:
posthog:query-llm-traces-list
{ "dateRange": { "date_from": "-7d" }, "filterTestAccounts": true }Then read each with query-llm-trace. Its one required argument is traceId, and the value to pass is
the trace's id from the list:
posthog:query-llm-trace
{ "traceId": "<id from a query-llm-traces-list result>" }Reading ~20–30 across a use case usually surfaces the main modes.
Existing-eval spikes
A jump in an existing eval's failures often exposes a new problem. Find the eval, then confirm the spike with a daily count and read the failing runs:
posthog:llma-evaluation-list { "enabled": true }SELECT toDate(timestamp) AS day, count() AS fails
FROM events
WHERE event = '$ai_evaluation' AND properties.$ai_evaluation_id = '<uuid>'
AND (<fail predicate>) AND (isNull(properties.$ai_evaluation_skipped) OR properties.$ai_evaluation_skipped != 'true')
AND (isNull(properties.$ai_evaluation_applicable) OR properties.$ai_evaluation_applicable != 'false')
AND timestamp >= now() - INTERVAL 30 DAY
GROUP BY day ORDER BY dayBuild <fail predicate> from the eval's output type and config, as in the fail predicate table in
exploring-llm-evaluations. $ai_evaluation_result = 'false' only fits a pass/fail eval that is not a detector.
exploring-llm-evaluations covers reading eval results in depth.
Counting failure modes
After open-noting and grouping (Step 3), a quick frequency count over the traces you tagged makes the ranking concrete — e.g. tally by a label you wrote into a scratch list, or, when the mode maps to a property, count it directly:
SELECT properties.$ai_model AS model, count() AS n
FROM events
WHERE event = '$ai_generation' AND properties.$ai_is_error = 'true'
AND timestamp >= now() - INTERVAL 7 DAY
GROUP BY model ORDER BY n DESCRequirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- PostHog
- Publisher
- PostHog (Official)
- Source
- PostHog/skills · skills/omnibus/exploring-ai-failures · commit a5d30e7
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by PostHog.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download exploring-ai-failures.zip