Langfuse scores — user feedback and automated quality signals on traces
Summary
Add Langfuse scores to the observability pipeline: user feedback (thumbs up/down or rating on assistant replies) and, later, automated quality signals are attached to the corresponding agent-turn trace as Langfuse score-create events. Users can rate a reply in the desktop UI and see that score on the trace in Langfuse within seconds.
Problem
We are completing a Langfuse observability overhaul: agent turns are traced end-to-end (traces/generations/tool spans with userId, sessionId, input/output, model, token usage including reasoning + cached tokens, cost, environment/release) via the core emitter in src/openhuman/agent/progress_tracing/, pushing through the backend proxy /telemetry/langfuse/ingestion (see tinyhumansai/backend#1069 for server-side userId stamping, plus the upcoming fix/langfuse-trace-metadata PR in this repo).
The missing piece is scores. Langfuse supports attaching feedback and quality signals to traces via the ingestion API (score-create events: traceId, name, value, optional comment/dataType), but today we have no way to record user feedback or automated quality verdicts against a trace. That means no signal in Langfuse about which turns were good or bad — which is the main reason to have traces in the first place.
Constraints: must respect the share_usage_data privacy gate (no telemetry when opted out), and must work for both managed (backend-proxied) and custom model configurations.
Solution (optional)
Scope: both (core + app), no backend change needed.
- Core —
score-createevents: extend the batch builder insrc/openhuman/agent/progress_tracing/langfuse.rswith ascore-createingestion event type. The core already knows the trace id per turn fromSpanCollector, so a score can be linked to the correct trace. - Core — RPC: new method
openhuman.observability_submit_score(domain: config/observability or agent) that accepts the turn/trace reference, score name, value, and optional comment, and enqueues ascore-createevent through the existing emitter. - Backend: no change — the
/telemetry/langfuse/ingestionproxy already forwards ingestion batches verbatim. - App — feedback UI: thumbs up/down (or rating) buttons on assistant replies in the chat thread UI, calling the new RPC via
core_rpc_relay. - Later (optional): automated scores — the triage evaluator in
src/openhuman/agent/triage/already computes quality/latency verdicts that could be exported as scores on the same traces.
Acceptance criteria
- [ ] Score visible on trace — submitting feedback in the UI produces a Langfuse score attached to the correct turn trace within seconds.
- [ ] Works for managed and custom models — scores flow for both backend-proxied inference and custom model configurations.
- [ ] Privacy gated — no score events are emitted when
share_usage_datais off. - [ ] Tests — unit tests for the
score-createbatch builder + RPC handler, andjson_rpc_e2ecoverage foropenhuman.observability_submit_score. - [ ] Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by
.github/workflows/pr-ci.yml).
Related
- tinyhumansai/backend#1069 — server-side
userIdstamping on the Langfuse ingestion proxy. - Upcoming
fix/langfuse-trace-metadataPR in this repo (trace metadata completeness). - Langfuse ingestion API
score-createevent type (traceId, name, value, comment, dataType).
Verified on main (6be58a9ab) — the tracing half is shipped, scores are not. PR #4505 is open and implements them.
What already exists. Langfuse trace export is live and wired end to end:
src/openhuman/agent/progress_tracing/langfuse.rs— a completed run's spans POST to the OpenHuman backend's Langfuse proxy route/telemetry/langfuse/ingestion, which forwards to/api/public/ingestion(backendsrc/services/langfuseProxy.ts). Clients never hold Langfuse keys.progress_tracing.rs:542—langfuse::push_spans(config, spans);:570—langfuse::push_observations(config, trace_ctx, observations, run_telemetry).- Config surface at
src/openhuman/config/schema/observability.rs(backend = "langfuse"), with tests.
What does not exist — scores. grep -rIn "score\|Score" across src/openhuman/agent/progress_tracing/ and observability.rs returns nothing. So today a trace lands in Langfuse and nothing can ever be attached to it: no user feedback, no automated quality signal. That is exactly what this issue asks for, and it is unimplemented.
Worth stating plainly because the presence of langfuse.rs makes this look done at a glance — the ingestion path is there, the score-create event type is not.
Status
PR #4505 ("feat: implement Langfuse feedback scores") is open, not draft, and unmerged, and it is a real implementation rather than a stub — 23 files:
| file | size |
|---|---|
src/openhuman/agent/progress_tracing/langfuse.rs |
+150 |
src/openhuman/agent/progress_tracing/rpc.rs |
+204 (new) |
src/openhuman/threads/tools.rs |
+63/-2 |
src/core/all.rs |
+13 |
src/openhuman/channels/providers/web/run_task.rs |
+6/-1 |
app/src/features/conversations/Conversations.tsx |
UI |
app/src/pages/__tests__/Conversations.feedback.test.tsx |
+387 (new) |
tests/json_rpc_e2e.rs |
+33 |
| i18n strings across 14 locales | — |
So this issue is genuinely in progress; the work just hasn't landed. Recommend tracking it to merge rather than re-planning it.
One thing worth confirming during review
The client pushes through the backend proxy specifically so Langfuse credentials stay server-side. Scores are a write path with a user-supplied payload, so the proxy route needs the same treatment as ingestion — that the backend, not the client, decides the Langfuse project/keys, and that a client cannot post a score against an arbitrary traceId it does not own. Worth an explicit check on the rpc.rs surface in #4505 before merge; it is the one place where "scores" differs in risk from "spans".
Leaving open until #4505 merges.
The UI + persistence half of this is now up as #6494: thumbs on an assistant reply, persisted per message via extraMetadata / openhuman.threads_message_update, with the pressed state surviving reloads and thread switches. No core change was needed for storage. The score-create half — the part that makes the rating readable — is still open, so #6494 deliberately does not close this issue.
Two findings from building it that change this issue's scope, both verified in code rather than inferred:
1. A score export would fire from staging only, so the stated goal does not hold for production users.
LANGFUSE_PUSH_ENVIRONMENTS = &["staging", "development"] (agent/progress_tracing/langfuse/environment.rs:106) is an explicit fail-closed allowlist — deliberately written as a list rather than != "production" so a new bucket does not silently start pushing. Production therefore never pushes, by design.
Worse, the doc comment at :120-127 records that the backend answers 403 FEATURE_DISABLED outside staging (backend#1291), so even development does not land against the real backend; the client-side skip exists only to avoid paying a round-trip to be told no.
So this issue's premise — "Users can rate a reply in the desktop UI and see that score on the trace in Langfuse within seconds" — is true for staging and not for production users as the pipeline stands. That seems worth deciding explicitly: either the goal is a staging/eval instrument, or the environment gate needs to change as part of this work. Right now the issue reads as though it delivers the former while describing the latter.
2. The rating is being stored today regardless, so the ordering is flexible.
#6494 writes extraMetadata.feedback = "positive"/"negative" on the assistant message row, keyed by (thread_id, message_id). Those rows are queryable whenever a consumer arrives, so the score exporter can be built against real accumulated data rather than needing to ship in lockstep with the UI. Nothing is lost by the halves landing separately.
One caveat for the exporter's author: one visible assistant message is often several persisted rows (mergeAssistantRun), and the rating is written against the last row's id. #6494 records the full set in extraMetadata.feedbackRowIds so the association is recoverable, but a consumer mapping a rating to a trace should read that key rather than assuming one row per reply.
Triage: valid — PR #6494 adds thumbs-up/down persistence, but no trace scoring or score-submit RPC exists; the issue’s core Langfuse acceptance criteria remain open.
Thanks. Update on current main: the rating half is in (#6494), so thumbs up/down on a reply is saved with the message. Nothing sends that rating to Langfuse yet: there's no score RPC, and the score client exists only in TinyAgents.
One earlier concern no longer applies: trace export now runs in production as well as staging and development, so a score sent alongside a trace would be visible for production users too. What's left is the score-submit path from a saved rating to the matching trace.