
A guide to evals for automations
Sofia Kuttner Lindelow, Forward Deployed AI Engineer
An automated returns workflow can send a customer a correctly worded refusal while creating the shipping label it was supposed to withhold. Someone reading the reply would see a successful decision; someone checking the order would find an error. Both are looking at the same run, but they are measuring different things.
Evaluating a workflow begins with operationalization, the process of defining which observable outcomes represent success and how those outcomes will be measured. "Handles returns well" leaves considerable room for interpretation. "Applies the correct policy, creates an authorization on the right order, and never promises a refund before the item arrives" gives you something to evaluate.
A custom benchmark records that definition in a set of cases with known inputs, expected outcomes, and scoring rules. An evaluation, or eval, runs the workflow against them. Public leaderboards can help identify models worth considering, but they cannot determine whether the resulting actions satisfy your return policy. That depends on a definition of acceptable work specific enough to test, and on cases that genuinely test it.
What you will learn
• How to define benchmark cases that measure the outcomes an AI workflow is responsible for.
• How to set up those cases in Langfuse and use repeated evaluations to assess a proposed workflow change.
What the score is supposed to represent
Consider an illustrative store policy allowing ordinary returns within 30 days but excluding non-faulty final-sale items. A customer wants to return boots that do not fit. The order was delivered nine days ago and is marked final sale. The correct outcome is a refusal explaining that restriction, with no return authorization or label created.
The delivery date matters because the case needs to distinguish a workflow that applies the final-sale rule from one that ignores it. If the order were also 41 days old, declining it would not establish which rule the workflow used. A separate full-price order outside the window can test the time limit. Although both cases end in a refusal, they provide evidence about different decisions.
This is the work that has to happen before a tool can produce a meaningful score. The person who handles returns knows which exceptions apply, which actions must occur, and which mistakes would make an otherwise reasonable response unusable. Their judgment becomes the expected outcome against which the workflow is assessed. Anthropic's guidance on agent evaluation similarly distinguishes the agent's account of what it did from the resulting state of the systems it touched.
For the boots case, the record could look like this:
Twenty or thirty cases are enough to begin finding weaknesses, provided they cover more than one kind of request. Include ordinary work, consequential mistakes, and situations that should reach a person, then inspect those groups separately. A set drawn entirely from difficult failures cannot estimate how often everyday traffic succeeds. Equally, a set of straightforward requests can give reassuring results while leaving the expensive exceptions untested.
How to apply the definition in Langfuse
Langfuse provides a place to store the cases, record executions, and compare results. The operator can prepare the inputs and expected outcomes, while a developer connects the application and implements its checks. Uploading a spreadsheet establishes the test data; the application still needs a way to execute each case and return evidence of what happened.
The expected outcome remains a reference held outside the agent's input, while the application produces its own decision and actions. A scoring function then compares that recorded result with the reference. In the boots case, the evidence has to include whether a label was created, because the refusal alone cannot establish whether the workflow met the requirement. That determines what the integration needs to record before anyone configures an experiment.
For a complete workflow, the developer uses Langfuse's software development kit, or SDK, a code library that connects the test runner to your application. A task function accepts each case, passes only its input to the workflow, and returns the decision, reply, recorded actions, and resulting test-system state. The developer then attaches scoring functions through the runner's evaluators list. Each compares actual and expected results and returns a named score with an explanation.
The decision and prohibited actions can be checked in code. If a label exists for TEST-022, no_prohibited_action scores zero even when the refusal reads correctly. Verify resulting state where an action should change it; the tool's own success message does not establish that the correct order was updated. A model judge can assess whether the explanation reflects the supplied policy, using a written rubric. Check its verdicts against a human reviewer's labels on acceptable and deliberately flawed replies, paying particular attention to bad replies it incorrectly passes. An uncertain verdict should go to a person.
Keep those individual scores alongside the overall result. For this example, every required check must pass, so a fluent explanation cannot compensate for a prohibited action. Time, cost, retries, and measured human correction time can then show what it takes to achieve that result.
Begin by creating a project and connecting the workflow through the Python or JavaScript/TypeScript integration. The developer instruments the relevant functions, adding code that records model calls, policy retrieval, and tool actions. Run a synthetic request and inspect its trace, the record of that execution. Seeing the final reply appear is insufficient if the retrieval and label-creation steps are absent, because those are the steps you will need to examine when the case fails.
The test environment also has to preserve the conditions the case describes. Use a frozen order snapshot, the applicable policy version, and a fixed time for calculating return windows. Reset the environment between attempts, and replace customer-facing actions with simulated tools or an isolated test store. Replaying a benchmark should not send real labels or alter customer orders. Remove identifying details before sending examples or traces to a hosted service.
In Project > Datasets > New dataset, create returns-working, then add cases manually or import a CSV. Map the three fields in the worked example to input, expected output, and metadata, following Langfuse's dataset instructions. The policy and order facts belong in input; the answer belongs in expected output, outside what the agent receives. Keep a separate returns-release dataset for cases reserved until the release comparison. Working cases can guide repairs, while reserved cases test whether a change carries beyond the examples used to develop it.
How you connect the dataset depends on what you are evaluating. For a single prompt, Langfuse's prompt experiments can run through the interface after you configure a model connection and match the prompt's variables to the dataset fields. Open the dataset, select Start Experiment, and choose the prompt, model connection, and evaluators. This tests the model's response to those inputs. Establishing whether the application also creates an incorrect label requires the surrounding workflow to run.
What a comparison can establish
Once the current workflow has run against the working cases, its results provide a baseline for evaluating changes. Record the application, prompt, model, dataset, and evaluator versions, and inspect existing failures before accepting that baseline. A first run is a starting measurement, not evidence that the current system meets every requirement.
Holding the dataset constant requires an explicit choice. Langfuse versions datasets by timestamp and otherwise retrieves the latest version. Save the chosen timestamp and fetch it with the SDK's version parameter, or select it in the prompt-experiment setup. Recording a version in your notes without using it to load the data will not preserve the comparison.
Repeat each case at unchanged settings in a clean environment, retaining every attempt's outcome. Language-model behaviour varies between runs, so a case that passes once and fails after an edit does not, by itself, show that the edit caused the failure. Compare successful attempts with total attempts for each case in both versions. Investigate critical prohibited actions even when the other attempts pass; a small average improvement does not settle whether those mistakes are acceptable.
After changing one thing, run the candidate against the same working dataset version and scoring rules. In Experiments, select the baseline and candidate runs and open the comparison view. Suppose the candidate improves several replies but creates a label for the final-sale boots. That violation justifies holding the release, even if the average rises; repeated comparisons are needed to assess whether the change increased the failure rate. Opening its trace can distinguish retrieval of the wrong policy, misinterpretation of the correct policy, and a label tool running despite a correct refusal. Each points to a different repair.
After development, evaluate both versions on the reserved release cases, again with repeated attempts and consistent checks. If a reserved case becomes an example you use to develop another fix, move it into the working set and replenish the reserved set. Correct faulty evaluators and re-score both versions before interpreting their differences; missing scores and execution errors also need resolving.
The release rule should be agreed before the candidate's results arrive. A team might require all critical cases to pass while preserving previously accepted behaviour elsewhere. Langfuse's comparison screen supports that review, but enforcing the rule in a deployment pipeline requires a separate continuous-integration configuration. The platform records the comparison; the team remains responsible for deciding which results justify a release.
Key takeaway
The first useful benchmark makes a small part of the work precise enough that someone can inspect the cases, understand the scores, and challenge the release decision. It will not represent every situation the workflow encounters, which is why production monitoring and human review continue after deployment. New failures should become cases in later dataset versions, preserving earlier versions for comparisons already made.
For a team beginning this process, the practical starting point is one recurring workflow and the person who understands its exceptions. Define the outcomes together, run the current process, and examine what the result demonstrates. Subsequent model and tool changes can be assessed against that standard. When the business changes its policy, revise the affected cases and review a new baseline, so the standard changes through an explicit decision rather than an unnoticed change in system behaviour.


