Index of every page on this site: llms.txt
All skills
trailofbits avatar

/langfuse

@298c01f
by Trail of Bitstrailofbits/buttercup1.8k stars
190
Run it yourself

Interact with Langfuse and access its documentation. Use when needing to (1) query or modify Langfuse data programmatically via the CLI — traces, prompts, datasets, scores, sessions, and any other API resource, (2) look up Langfuse documentation, concepts, integration guides, or SDK usage, or (3) understand how any Langfuse feature works. This skill covers CLI-based API access (via npx) and multiple documentation retrieval methods.

  • 8 files
  • 43.3 KB
  • Updated 6 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/trailofbits/buttercup/langfuse

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesuser-feedback.md

≈1.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

User Feedback

Tracing must already be set up — feedback is stored as scores on traces.

Docs: https://langfuse.com/docs/observability/features/user-feedback

Workflow

1. Determine What Feedback to Capture

If the user has asked for something specific, go with that. Otherwise, look at the application and present a few UX options for how feedback could work, then ask the user which they prefer before implementing.

Common UX patterns to suggest:

UX Pattern Best for How it works
Thumbs up/down Chat apps, Q&A Simple binary buttons next to each response
Star rating (1–5) Content generation, summaries Star row or dropdown after each output
"Was this helpful?" banner Search, documentation assistants Single yes/no prompt at the bottom of a response
Regenerate / copy tracking Any app with these actions Implicit — log when users retry (negative signal) or copy output (positive signal)
Free-text comment Complex outputs, internal tools Optional text field alongside a rating
Report button Any user-facing app Flag icon to report bad/harmful responses

This table is not exhaustive — if the application suggests a different feedback pattern that fits better, propose that instead. Present 2–3 options that match the application's use case and ask the user which approach they'd like. This decision shapes everything downstream (score names, data types, frontend components), so it's important to align early.

Feedback can be explicit (user rates via thumbs, stars, etc.) or implicit (derived from behavior like copying output, retrying, or escalating to support). Both are stored as scores. Explicit feedback requires the trace ID to reach the frontend; implicit feedback is logged server-side where the event already happens.

2. Choose Score Names

Name reflects the signal source, not what you hope it measures (e.g., user-thumbs not response-quality — a thumbs down doesn't tell you what was wrong). Avoid generic names like feedback or score.

Rules:

  • Lowercase with hyphens
  • One consistent name per feedback type across the entire app
  • If capturing multiple signals, each gets its own distinct name

3. Implement Score Creation

For implicit feedback (server-side): Use langfuse.create_score() / langfuse.score.create() wherever the event is already handled in application code. Fetch SDK docs for current API: https://langfuse.com/docs/evaluation/evaluation-methods/scores-via-sdk

For explicit feedback (frontend): Use LangfuseWeb in the browser. It uses the public key only — no secret key exposed.

import { LangfuseWeb } from "langfuse";

const langfuse = new LangfuseWeb({
  publicKey: process.env.NEXT_PUBLIC_LANGFUSE_PUBLIC_KEY!,
  baseUrl: process.env.NEXT_PUBLIC_LANGFUSE_HOST,
});

langfuse.score({
  traceId,
  name: "user-thumbs",
  value: 1, // 1 = positive, 0 = negative
  dataType: "BOOLEAN",
  comment: optionalUserComment,
});

The trace ID must be available in the frontend for this to work. For Vercel AI SDK, the non-obvious pattern is using generateMessageId:

import { getActiveTraceId } from "@langfuse/tracing";

// Inside route handler wrapped with observe()
return result.toUIMessageStreamResponse({
  generateMessageId: () => getActiveTraceId() || crypto.randomUUID(),
});

4. Verify

Trigger a feedback action and check the trace's Scores tab in Langfuse. Confirm the score name, value, and data type are correct.

Point users to what they can do with feedback data: filter traces by low scores, use score analytics for trends, build annotation queues for team review.

Common Mistakes

Mistake Problem Fix
Secret key in frontend code Security risk Use LangfuseWeb with public key only
Missing dataType on boolean scores Value 1 inferred as NUMERIC Always pass dataType: "BOOLEAN" explicitly
Inconsistent score names across the app Can't aggregate or filter reliably Pick one name per feedback type, use it everywhere

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 298c01f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated 6 months ago
What it can do
Network Runs commands
All 10 allowed tools
WebFetch(domain:langfuse.com)Bash(curl *langfuse.com/*)Bash(npx langfuse-cli api __schema *)Bash(npx langfuse-cli api * --help *)Bash(npx langfuse-cli api * list *)Bash(npx langfuse-cli api * get *)Bash(bunx langfuse-cli api __schema *)Bash(bunx langfuse-cli api * --help *)Bash(bunx langfuse-cli api * list *)Bash(bunx langfuse-cli api * get *)

README badge

README badge for trailofbits/buttercup/langfuse