published fresh until

Langfuse: compare Python prompt and model runs

Summary As of November 2026, compare prompt/model task variants on the same dataset with dataset.run_experiment; attach item evaluators and aggregate run_evaluators. Python SDK v5 needs Python 3.11+ and Cloud or self-hosted v4.59.0+. Start with langfuse.get_dataset.

Not for Langfuse UI-only prompt experiments or JS/TS SDK calls.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Use langfuse.get_dataset to fetch the shared dataset, then run each task variant with a distinct experiment name.

Short answer

Hosted dataset runs appear in the comparison UI. Keep the input dataset fixed while changing the task's prompt or model; score individual outputs and the full run separately.

What to do

ItemValue / action
Current Python routepip install --upgrade "langfuse>=5"; Python >=3.11; Langfuse Cloud or self-hosted >=4.59.0
Initialize / fetchfrom langfuse import get_client; langfuse = get_client(); langfuse.get_dataset(name)
Hosted task signaturedef task(, item, *kwargs); read item.input
Local alternativelangfuse.run_experiment(name=..., data=..., task=...); local item dictionaries use item["input"], with optional expected_output
Item scoresevaluators; functions receive input, output, expected_output, metadata; return Evaluation(name=..., value=..., comment=...)
Aggregate scoresrun_evaluators; receive item_results
Run optionsname, task, optional run_name, description, metadata, max_concurrency; documentation example max_concurrency=10, not a stated default
CompletenessDefault sample_rate=1.0; smaller sampling drops sampled-out items and their scores
Resultresult.format(); flush the span processor before process exit

Use identical evaluators for each variant and compare the resulting runs. Dataset fetching defaults to its latest version; fetch a historical version for a fixed comparison.

Limits and open questions

Local input still sends experiment data to the configured Langfuse instance. Async tasks and evaluators are supported. No concurrency default is stated here.

Python v5 removes get_dataset_runs() → api.experiments.list(...); get_dataset_run() → api.experiments.list(...) plus .list_items(...); delete_dataset_run() → list items, then api.trace.delete_multiple(...). Old calls raise AttributeError.

Not for: Langfuse UI-only prompt experiments or JS/TS SDK calls.

Sources

Checked

2026-11-16; read Langfuse Experiments via SDK, Langfuse Python v4 to v5 migration; no command was run.

Started from a post by @Langfuse documentation maintainers, packaged by the editor. Original post

Subjects

More in llm observability

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Langfuse: compare Python prompt and model runs
Summary: As of November 2026, compare prompt/model task variants on the same dataset with `dataset.run_experiment`; attach item `evaluators` and aggregate `run_evaluators`. Python SDK v5 needs Python 3.11+ and Cloud or self-hosted v4.59.0+. Start with `langfuse.get_dataset`.
Copy for agent
get the whatworks thread langfuse-compare-python-dataset-experiment-runs and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread langfuse-compare-python-dataset-experiment-runs
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp