Set these environment variables to enable LangFuse:
LANGFUSE_ENABLED=trueLANGFUSE_PUBLIC_KEY=pk-lf-...LANGFUSE_SECRET_KEY=sk-lf-...LANGFUSE_HOST=https://cloud.langfuse.comLANGFUSE_RELEASE=<optional app version>LANGFUSE_ENV=<optional env: dev|staging|prod>
- LangSmith continues to trace workflow and node execution for the LangGraph pipeline.
- LangFuse records individual non-streaming LLM generations wrapped by
_invoke_llm(). - LangFuse also stores user feedback scores and the synced golden-query dataset.
The API exposes:
POST /sessions/{session_id}/runs/{run_id}/feedback
Request body:
{
"helpful": true,
"comment": "Optional note"
}Rules:
- Only one feedback submission is allowed per run in this iteration.
- The run must be
completed. - The run must have LangFuse trace metadata persisted on it. If missing, backend attempts an on-demand LangFuse anchor linkage first.
- Comments are optional, trimmed, and limited to 500 characters.
The research UI shows a simple thumbs up/down control for the latest visible completed run. A thumbs down reveals an optional comment box.
The checked-in source of truth lives at:
tests/fixtures/langfuse_golden_queries.json
Each item contains:
idinputrubrictags- optional
difficulty - optional
notes
This artifact is intentionally rubric-based rather than exact-output based so the benchmark remains stable for generative research/report answers.
Sync the checked-in artifact into LangFuse:
uv run python scripts/sync_langfuse_dataset.pyOptional flags:
--dataset-name cortex/golden-queries--source tests/fixtures/langfuse_golden_queries.json
The sync is explicit and idempotent. It creates the dataset if missing and upserts items by stable item id.
- Review weak traces or generations in LangFuse.
- Curate the useful failures into
tests/fixtures/langfuse_golden_queries.json. - Re-run dataset sync.
- Use the LangFuse dataset and experiments for regression tracking.
This keeps git as the benchmark source of truth while still using LangFuse UI as the operational discovery surface.