Skip to content

feat: wire 👍/👎 feedback to Langfuse Scores (#144)#154

Merged
hweej merged 2 commits into
mainfrom
feat/langfuse-feedback-scores
May 21, 2026
Merged

feat: wire 👍/👎 feedback to Langfuse Scores (#144)#154
hweej merged 2 commits into
mainfrom
feat/langfuse-feedback-scores

Conversation

@hweej
Copy link
Copy Markdown
Contributor

@hweej hweej commented May 21, 2026

Summary

  • TurnTrace exposes trace_id (captured via get_current_trace_id() after the root span opens)
  • Done event carries trace_id; agent emits it
  • New nullable chat_messages.langfuse_trace_id column (alembic migration 092e2aa153ce); set when persisting the assistant message
  • PUT /feedback forwards rating to create_score(name="user_feedback", value=1.0/0.0, data_type="NUMERIC", trace_id=..., score_id="feedback-{user_sub}-{message_id}") — only when trace_id is present
  • Deterministic score_id so re-clicks update in place (assuming Langfuse upserts; duplicates are prefix-greppable for cleanup if not)
  • DELETE /feedback leaves Langfuse history alone (dashboard retains the previous rating)
  • Forwarding is best-effort: a broken Langfuse client logs and swallows

Closes #144.

Test plan

  • 273 API tests + 252 agent tests passing (+7 new feedback/trace tests)
  • CI green
  • After merge: rebuild API docker, restart, apply migration, verify a 👍 click on a new turn produces a Langfuse Score with name=user_feedback, value=1.0

hweej added 2 commits May 21, 2026 09:36
- TurnTrace exposes trace_id via get_current_trace_id() after root span opens
- Done event carries trace_id; agent emits it
- ChatMessageRow has nullable langfuse_trace_id (alembic migration)
- FakeLangfuseClient mocks get_current_trace_id + records create_score calls
- chat route persists Done.trace_id on the assistant message row
- PUT /feedback forwards rating to Langfuse create_score (name=user_feedback,
  value=1.0/0.0, deterministic score_id for upsert semantics)
- DELETE /feedback does not touch Langfuse — history preserved on the dashboard
- Forward is best-effort: failures logged, never bubble up to the client
@hweej hweej self-assigned this May 21, 2026
@hweej hweej added the enhancement New feature or request label May 21, 2026
@hweej hweej merged commit 245be72 into main May 21, 2026
3 checks passed
@hweej hweej deleted the feat/langfuse-feedback-scores branch May 21, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Langfuse: wire 👍/👎 feedback to Langfuse Scores

1 participant