What can a trace change?
A trace helps explain why time or cost increased and where to look for an improvement. A successful tool call alone does not establish that the user's task was achieved or useful. Connect the original request to acceptance and later rework, and include the cost of observability itself in the comparison.
This design uses sources checked on November 7, 2026. Company reports, research experiments, and tutorials have different evidentiary weight. The alerts and repair actions below are examples, not configurations we deployed or tested. For collection paths, see coding-agent trace collection.
- 1Outcome path: request
- 2acceptance
- 3later outcomes and rework
- 1Improvement path: metrics and sampled traces
- 2hypothesis
- 3evaluation
- 4gradual rollout
- 1Decision path: outcomes and cost
- 2keep or revert
Connect a request ID to run IDs and keep canceled and unfinished work in the request denominator. Agent termination, passing tests, and user acceptance are distinct events. For coding, include review, changes, and post-merge defects rather than stopping at PR creation. Outcomes outside the observation window remain unknown.
What happens after an alert?
| Signal | First response | Condition for automation |
|---|---|---|
| p95 duration rises for comparable tasks | Inspect slow spans, external wait time, and repeated tool calls | Retry temporary limits with a bounded count and delay; prevent duplicate writes |
| Cost per request rises | Check call count, model, input length, and duplicate accounting | Stop at a budget or propose a cheaper candidate; test quality separately |
| Acceptance or evaluation score falls | Compare failures with human feedback | Generate a candidate in a sandbox; test and have a person decide whether to use it |
| Telemetry is missing or export fails | Inspect missingness, exporter queue, and credentials | Bound retries, deduplicate, and alert on missing telemetry itself |
For example, compare a one-hour p95 against a baseline for the same task type and model, and alert only with a minimum number of observations. Account for late scores, duplicate notifications, and the distinction between zero traffic and a broken collector. Set the threshold from the users' tolerance for that task. Langfuse Alerts can monitor latency, cost, and scores and route notifications to Slack, PagerDuty, or a webhook. Its default treats missing data as zero, so configure an appropriate missing-data notification separately.
A webhook firing is not evidence that a repair succeeded safely. Bounded backoff for a 429 response is a candidate for automation; unlimited retries with unchanged inputs can increase cost. For actions that alter production data or publish changes, implement authorization, validation, approval, and a way to revert. Check whether the user task succeeded as well as whether the alert cleared.
How much self-improvement is actually happening?
- 1Case selection: failure and feedback
- 2human checks reason
- 3add evaluation case
- 1Candidate validation: development cases
- 2held-out cases
- 3limited rollout
- 4measure in use
Repeatedly changing a system against the same cases can overfit them. An agent can propose changes, but the validity of the judge, held-out cases, safety, and actual post-release results need independent checks. Have people check a sample of LLM judgments and include the judge's cost and errors.
| Case | Action from the record | What the evidence establishes |
|---|---|---|
| LayerX | Built Langfuse datasets for an expense-application review example and compared prompts and models through experiments | Describes an evaluation workflow; production prompts are managed in code with regression tests on deployment. It does not establish unattended self-improvement or ROI |
| NTT DATA / Datadog | Used evaluations for model selection during AgentCore pre-production validation | The vendor case reports about 50% lower inference cost and 70% lower MTTR. It does not provide a controlled study including observability costs, so causation by tracing alone is unknown |
| LangChain | Asked an AI assistant to inspect a roughly 150-step trace, found repeated reads of the same file, and changed a prompt | A provider's example without a quantified before/after result or evidence of unattended deployment |
| AgentGuard | Generated conditional guardrails from failure traces and evaluated them on 100 separate tasks | A 2026 preprint reports abnormal executions falling from 69.0% to 26.7% and success rising from 21.7% to 35.0%. Humans judged runs on deliberately problematic tasks; this is not proof of production ROI or autonomous deployment |
| OpenAI Cookbook | Uses traces and feedback from fictional company data to build evaluations and improvement candidates | A teaching example, not evidence of ongoing autonomous production improvement or profit |
Separate population metrics from detailed samples
Record lightweight start, end, acceptance, cost, duration, and telemetry missingness for every request where the source permits. Then retain redacted detailed traces at a chosen rate for successful cases and at a higher rate for failures or high-cost cases. Decide separately what content to collect, where to send it, how long to keep it, and who can access it. Sampling cannot recover information the client never emitted.
Langfuse SDK sampling defaults to collecting every trace and samples at trace level when configured. Check whether a specific client integration actually uses that SDK setting. If a session has several trace IDs, independently sampling traces can leave only fragments of a conversation. To compare whole sessions, design consistent selection using a shared session ID.
Oversampling failures makes their share of saved traces larger than their share of all requests. In a hypothetical million runs with 10,000 failures, retaining all failures and 5% of successes stores 59,500 traces; the observed failure share is about 16.8%, although the population rate is 1%. Known inclusion probabilities permit weighted estimation under suitable assumptions; prefer population counts when available and do not estimate strata with unknown or zero inclusion probability.
Tail sampling can select failures after their outcome is known, but requires waiting and memory and may miss spans that arrive late. Route spans of a trace to the same collector and monitor decision delay and loss. Content discarded before the decision cannot be recovered. See the Grafana tail sampling guide for collector placement.
Storage bytes are only one observability cost. Include events, ingestion, retention, queries, transport, collector operations, model-based grading, and human investigation. Billing units differ by vendor, and SDK sampling and online-evaluation sampling are separate. Start with a small sample, measure spans and average size per request, judge calls, and the actual bill, then adjust detail and retention.
Compare user value with total cost
Define acceptance and the measurement window before running the comparison. Check whether the result serves the user's purpose, then track acceptance rate, later fixes or reopenings, and user feedback. Elapsed time from request to acceptance and active human work including review and rework are different measures. Include failed and canceled requests and compare similar task types and difficulty.
Total cost per accepted task = total cost in period / accepted tasks
Incremental net benefit = added outcome value + realized savings - incremental costs
ROI = incremental net benefit / additional investment (when investment is positive)Total cost includes incremental model and seat charges, tools, observability, storage, evaluation models, human review, operations, and incident response. Less staff time at a fixed salary is not automatically a cash saving. If valuing freed capacity, state the assumption and avoid adding revenue and opportunity value for the same effect twice. Even a lower cost per accepted task can coincide with lower overall value if important requests are missed.
For an illustrative 100 requests, suppose humans accept 90 at a total cost of ¥1.15 million, while AI-assisted work accepts 80 at ¥1 million. Cost per accepted request falls from about ¥12,778 to ¥12,500. Yet, if each accepted task is provisionally valued at ¥20,000, outcome value minus total cost falls from ¥650,000 to ¥600,000. This simplified example assumes equal value per task; valuing fixed-salary hours does not establish cash savings.
To estimate causation, randomly assign requests in advance to AI-assisted and comparison groups when feasible. Analyze all assigned work, including cancellations, and report sample size, uncertainty, and missing follow-up. In METR's 2025 experiment, experienced OSS developers in a particular setting took 19% longer with the AI tools tested. That result is specific to its time and participants. A 2026 update explains that selection bias and other issues prevent a confident estimate of effect size. Measure newer agents and different work in their own setting.
A first small experiment
- Pick one task type and define request ID, acceptance, observation window, and comparison group. Record failures and cancellations.
- Record population counts, time, acceptance, and cost. Use synthetic data to verify events and missingness in the chosen integration.
- Sample a small number of complete sessions and review failures safely. Record inclusion probability, retention, and evaluation and observability costs.
- Select one failure pattern and compare the change against held-out cases. After a limited rollout, use acceptance and total cost to decide whether to keep or revert it.
MENTAL MODEL / VERIFICATION COST
The value of a decision depends on downstream work.
Assumptions: one second for the judgment, half of the candidates retained, and equal verification time. Full parallelism needs enough compute and concurrency. Compare success rate and total cost, including wrong judgments and retries. These figures are estimates, not measurements.
Sources
Publication dates belong to the source; access dates record when it was checked. Community observations are separate from official statements.
01