Skip to content

Feat/langfuse integration + langfuse v3 - #44

Open
fidok15 wants to merge 4 commits into
mainfrom
feat/langfuse-integration
Open

Feat/langfuse integration + langfuse v3 #44
fidok15 wants to merge 4 commits into
mainfrom
feat/langfuse-integration

Conversation

@fidok15

@fidok15 fidok15 commented Jul 29, 2026

Copy link
Copy Markdown
Member

Langfuse was wired up but the data was useless — one global CallbackHandler meant every request wrote into the same trace, concurrent requests overwrote each other's handler on the RAG object, and the final-answer LLM call wasn't traced at all.

What changed:

  • trace_id is generated per request in the ToPWR API and passed down to the MCP server
  • handler is created per request and travels through LangGraph state instead of self.handler, so parallel requests can't mix traces
  • moved handler setup to the Langfuse v3 API (trace_context — the old constructor kwargs crash on v3)
  • final answer call is traced under the same trace_id, so one user request = one trace: Guardrails → Generate Cypher + Final Answer
  • real session_id is propagated end to end (was: trace_id reused as session), so conversations group correctly in the Sessions view
  • both servers flush Langfuse on shutdown (lifespan / atexit)

@fidok15 fidok15 self-assigned this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant