A user gives your agent's answer a thumbs-down. You open the trace in Langfuse and read it step by step: the model's calls, the tool arguments, the results. Twenty minutes later you find it. A tool returned an error, and the model told the customer about a store policy it had never looked up.
I did this many times at my last job, on an LLM assistant built into a B2B product, with agent tools on top of our GraphQL API. Each thumbs-down went into Langfuse, I found what went wrong, and I turned it into a promptfoo eval case so the same failure couldn't come back quietly.
That reading is slow and repetitive, so I built a Claude Code skill to do it. Then I did what most tool posts skip: I planted bugs in a demo agent, applied the fixes, and measured whether they worked. Some results backed up what I believed. One was a regression I didn't see coming. And my own tool did worse at its main job than I had claimed.
What the skill does
You give it a Langfuse trace ID or an exported trace file. A small script pulls the trace and prints a compact timeline. Here's the start of one, for a customer who asked to cancel "order 10571":
USER MESSAGE Please cancel order 10571. TIMELINE [generation 1] llm-call-1 requested tool calls: - cancel_order {"order_id": "10571"} [tool call] cancel_order ERROR result: {"error": "Invalid order_id: \"10571\""} [generation 2] llm-call-2 text: I apologize for the inconvenience, but I couldn't locate order 10571 in our system. ... The skill reads that timeline alongside the tool definitions the agent had at the time, and writes a report with:
- a failure type from a fixed list of ten: wrong tool, wrong arguments, missing tool call, unnecessary tool call, overlapping tool descriptions, mishandled tool error, leaked internals, prompt issue, model error, inconclusive
- evidence quoted from the trace, with a confidence level
- where the fix belongs, with a before/after diff
- a promptfoo test that replays the failing model step
The fixed list matters more than it looks. Without one, the model writes a fresh paragraph of diagnosis every time, and you can't count or compare reports across a week of traces. "Inconclusive" is on the list deliberately: if the trace doesn't show the cause, the report should say so and name the data that would settle it.
Heads-up if you build on the Langfuse API. Langfuse Cloud stopped serving the single-trace endpoint,
GET /api/public/traces/{id}, on 16 November 2026. The fetch script now rebuilds a trace from the v2 observations API (GET /api/public/v2/observations?traceId=...) and the v3 scores API, and falls back to the old endpoint for self-hosted servers. See Langfuse's migration guide.
The rule: keep one-tool fixes out of the system prompt
Every report has to say where its fix belongs, and the skill is biased against the system prompt. The rule comes from that same job: if a rule only applies to one tool, it lives in that tool's description, schema or server behaviour, not in the prompt.
Our assistant's v1 system prompt loaded the whole tool list, plus rules that each mattered to only one tool. In v2 I replaced it with a short generic prompt and moved the tools into skills the model loads on demand. To check the effect, I replayed the same complete user flows against v1 and v2 and compared total tokens per flow: about 60% fewer in v2. That figure is net of the extra steps where the model loads a skill. Both changes shipped together, so I can't split the saving between them.
The prompt is the easiest place to put a fix, and that's the problem. Every one-tool rule you add there is paid for on every call. It also sits far from the code it describes, so the next person to change the tool never sees it.
That was the theory. I wanted to test it.
A demo agent built to fail
I can't publish traces from a real product, so I built a small agent designed to break: customer support for an online bookstore, five tools, fake data in memory. Two flaws were planted:
- The order ID format is never stated. IDs look like
BK-10571, and nothing tells the model so. -
cancel_orderandstart_returnoverlap. One says "Undo an order", the other "Reverse an order", and neither says which order status it applies to.
The agent runs on llama3.2:3b through Ollama, on a 2019 Intel MacBook, CPU only. A 3B model was a deliberate choice, not just a cost one: the skill's job is diagnosing failures, and a small model produces plenty of them. The agent talks to any OpenAI-compatible endpoint, so a stronger model is a one-line .env change. (Whether these failures survive on a stronger model is the obvious next question. See the end.)
I wrote eight scenarios. In the first run, five failed. Two scenarios didn't behave as designed, and I kept both as they happened: one meant to catch the model answering a policy question from memory, which instead called get_store_policy, and one meant to make it cancel a delivered order, which instead correctly called start_return.
The experiment
To separate the two kinds of fix, I built four versions of the tools:
| Variant | What changes |
|---|---|
flawed | nothing |
desc_only | the order_id description states the format: BK- followed by 5 digits |
errors_only | error messages say what to do next, not only what failed |
fixed | both |
The overlapping cancel/return descriptions stayed flawed in every variant, as a control.
This is the description fix:
- "description": "The order ID" + "description": "The order ID. Format: BK- followed by 5 digits, e.g. BK-10571." And this is the error fix for a return on an order that hasn't shipped:
- Order BK-10571 is not eligible for return because its status is processing. + Order BK-10571 has not shipped, so it can't be returned. It can be cancelled instead with cancel_order. Each scenario ran 3 times on each variant at temperature 0, with the pass/fail rules written down before any run (78 runs in total). A second batch ran at temperature 0.7, 5 runs each, on the three scenarios the fixes target (30 runs). Failures out of 3:
| Scenario | flawed | desc_only | errors_only | fixed |
|---|---|---|---|---|
cancel_bare_number: customer gives "10571" | 3/3 | 0/3 | 3/3 | 0/3 |
return_processing_order: return an order that hasn't shipped | 3/3 | 3/3 | 0/3 | 0/3 |
cancel_shipped_order: cancel an order that has shipped | 3/3 | 3/3 | 3/3* | 3/3* |
undo_delivered_order: "undo" a delivered order | 0/3 | 3/3 | 0/3 | 3/3 |
unneeded_lookup: question that needs no tool | 3/3 | 3/3 | 3/3 | 3/3 |
| 3 control scenarios | 0/3 | — | — | 0/3 |
Result 1: each kind of fix solves one kind of failure
Knowledge gaps are fixed in the description. With the format stated, the model sends BK-10571 and the order is cancelled. The error fix alone didn't help here. The model did learn the format from the improved error, but then asked the customer to supply it instead of retrying. The problem moved to the customer.
Failures after an error are fixed in the error message. This is the before and after I like most. On flawed, after start_return failed, the agent said:
As per our store policy, we can only initiate returns for orders that are in the shipped or delivered state.
That policy doesn't exist. On errors_only and fixed, it said:
Since the book has not shipped yet, we can't process a return. However, I can help you cancel the order instead.
The description fix alone left this at 3/3 failures. At that point in the conversation, the model is reading the error message, not the tool list. If the error only says what failed, the model guesses what to do next.
Neither fix did the other's job. At temperature 0.7, where all 30 runs produced different outputs, the pattern held: cancel_bare_number went from 5/5 failures to 0/5, and return_processing_order from 3/5 to 0/5.
* cancel_shipped_order depends on how strictly you grade it. The rule I set before the runs fails any sentence that offers a return without mentioning delivery. The fixed answer says "you can initiate a return by contacting our customer service team", and the next sentence adds "once the item has been delivered." By the rule I wrote down in advance, that's a fail. Having read the answer, I think it's a pass. Both readings are in the repo.
Result 2: a one-line description fix broke an unrelated flow
I didn't expect this one. undo_delivered_order passed on flawed: the agent correctly called start_return. With the description fix, its first call became cancel_order, 3 runs out of 3. Then it ignored the improved error ("It can be returned instead with start_return") and sent the customer to customer service.
Running the two fixes separately pinned it down: desc_only causes it, and errors_only doesn't. That makes sense, because an error message can't affect a first call that happens before any error. Why stating an ID format pushes a 3B model toward a different tool is something I didn't measure. My guess is the unfixed cancel/return overlap: the model was already close to undecided, and any wording change could tip it.
The lesson goes beyond this demo: a tool description edit is a change to every flow that sees that tool, not only the flow you were fixing. If I had checked only the failing scenario, I would have shipped a regression. This is the case for running the whole eval suite on every tool-description change, not just the new test.
How the skill did against the ground truth
Because I planted the flaws, I knew the right answers. So I scored the skill.
There are three versions of the skill in this table. The original reports came from an early version that could also read the demo's code. Before the experiment I added a rule that the skill may use only the trace itself ("v1"). Afterwards I made a "v2" with two more changes: a tie-break rule (label the root cause, not the symptom) and an explicit fix_location field, plus a fix for clean runs being filed as "inconclusive". v1 and v2 were scored on the same 12 failed traces, with expected answers frozen before v2 ran.
On traces where the agent actually failed:
| Original (could read code) | Trace-only v1 | Trace-only v2 | |
|---|---|---|---|
| Traces | 4 | 12 | 12 |
| Failure type right | 4 of 4 | 8 of 12 | 4 of 12 |
| Right fix location named first | 4 of 4 | 4 of 12 | 3 of 12 |
| Right fix location named anywhere | 4 of 4 | 7 of 12 | 5 of 12 |
| Failed run reported as "no failure" | 0 of 4 | 1 of 12 | 3 of 12 |
Across all 72 reports, including the clean traces, none suggested a system-prompt edit.
The good part: it never suggested the system prompt. The bias I designed in works.
The bad part is the location rows. The skill's main job is telling you which file to open, and the trace-only versions named the right file first about a third of the time or less. Its mistakes were close to backwards. For the missing ID format it led with the error message, and for the failures after an error it mostly led with the tool description. My own variant runs show both choices are wrong for this demo.
v2 fixed the format and made the diagnosis worse. The format changes worked: clean runs filed as "inconclusive" went from 4 reports to 0, and false positives on the fixed traces went from 3 of 7 to 0 of 7. But v2 called more real failures clean. All three cancel_shipped_order reports now say "No failure found", and in one of them the bad offers v1 had flagged were moved to a "Notes" section. My new format text probably caused that. It told the skill that an oddity it couldn't settle "is a note", and gave as the example "a possible problem in an offer the agent made", which describes exactly this failure. I wrote an instruction to cut false positives, and it also hid real failures. That's the precision/recall tradeoff, in a prompt.
There's a deeper limit here too. In cancel_shipped_order, the agent offered a return on an order that had shipped but not been delivered. The rule that returns need delivery isn't in the trace: it's in the server code, and the flawed error message never mentions it. So a trace-only reader can't prove that offer is wrong. The honest verdict is "inconclusive: check whether shipped orders can be returned", and that's what the label is for. The original reports could read the code, and they got all four failing traces right. My hypothesis is that the trace-only rule removed exactly what the skill needed. Diagnosis from the trace alone has a ceiling: business rules the trace never shows. That's a hypothesis from a small sample, not a measurement.
I've stopped tuning the skill here. With 12 failed traces and one triage each, every further prompt tweak would be fitting the skill to my own test set.
Other things it got wrong, all of which are in the repo:
- A confident false positive. On
undo_delivered_order, where the agent did the right thing, the skill reported "overlapping tool descriptions" with high confidence. - A false fact. One report said the store doesn't stock Dune. It does.
search_bookscan't match a title and author in the same query, a bug I hadn't planted, and the trace alone can't reveal it. - An invented status. One suggested fix described orders with status
"paid". This store has no such status. - Untested tests. The skill ran without permission to execute promptfoo, so no report checked its own test.
A testing lesson: replays can't see error fixes
The promptfoo tests the skill writes replay a single model step. Run against the fixed tools, they went from 15/30 passes to 18/30, and all of the gain came from the description fix. The error fix that solved return_processing_order in the live agent never showed up, because a replay feeds the model the recorded error text, which is the old, flawed one.
If your fix changes what a tool returns, a one-step replay can't see it. You need a test that runs the actual tool.
What's next
- A stronger model. Some of these failures are probably a 3B model being a 3B model. I want to know which.
- Fresh traces before more skill changes. Any further skill change gets scored on new traces I haven't tuned against. The first candidates: let the skill read the tool server's code (read-only) and see whether the location calls recover, and make "possible problem in an offer" an
inconclusivefinding again instead of a note. - Batch counts. Run the skill over a week of traces and count failure types. That's where the fixed list pays off.
The limits, plainly: one small model, one machine, scenarios I wrote myself, and failure checks that are regular expressions I validated by reading the answers. The ground truth for planted flaws was fixed when I designed the scenarios, but some labels are judgement calls, and those are marked in the repo. Every number in this post links to a committed file.
Try it
You don't need a Langfuse account or a model endpoint:
git clone https://github.com/hassanhere99/langfuse-trace-triage && cd langfuse-trace-triage claude --plugin-dir . Then ask it to triage examples/traces/cancel_bare_number.json. The experiment, every trace, the scoring scripts and a "what didn't work" section are in experiments/.
How this was built
I wrote the brief, made the design calls and set the rules for the experiment. Claude Code wrote most of the code and ran the experiment while I reviewed each step and sent changes back. I also used Claude to review drafts of this post. All the experience, opinions and conclusions are my own.
The most useful moments were unglamorous ones: stopping to ask for API keys instead of inventing traces, noticing that my shell still had another project's Langfuse keys exported, and noticing that Ollama was updated in the middle of the experiment. It added a control run to check the update hadn't changed the results. It hadn't changed the tool choices or the failure counts.
The repo is MIT licensed, with 201 tests running in CI: github.com/hassanhere99/langfuse-trace-triage
Muhammad Hassan (@hassanhere99)

