Langfuse TypeScript RAG evaluation with retrieval and answer regression tests
Use a Langfuse experiment to keep the RAG input, expected answer, retrieved context, output, item scores, aggregate quality, and regression threshold in one TypeScript evaluation run.
When to choose this path
The important implementation detail is to return the retrieved passages with the answer. That lets the experiment separate retrieval failures from generation failures instead of reducing both to one opaque score.
The complete TypeScript path
answer and retrievedContext.const result = await context.runExperiment({
name: "PR gate: RAG quality",
task: runCandidate,
evaluators: [answerCorrectness, retrievedContextCoverage],
runEvaluators: [averageRagQuality],
});
if (quality < 0.8) {
throw new RegressionError({ result, metric: "average_rag_quality", value: quality, threshold: 0.8 });
}
Open the complete type-checked RAG experiment.
What the independent benchmark found
Current evidence path
Langfuse documents JavaScript/TypeScript experiments, datasets, custom evaluators, experiment comparison, RAG faithfulness guidance, and a Ragas integration.
Search representation gap
In a 16-attempt Claude Code RAG-evaluation panel, Langfuse was named in most search receipts, but no Langfuse-owned page or AgentAnalytics Langfuse page appeared in the listed URLs. Ragas was selected 12/16, Braintrust 4/16, and Langfuse 0/16.
Primary sources
Limits
- The example proves TypeScript interface compatibility, not live service behavior or metric validity.
- The benchmark required research and is not an estimate of ordinary no-search provider share.
- No provider paid for inclusion, placement, wording, or removal.