ProjectTech4DevAI / ProjectTech4DevAI/kaapi-backend

Remove Langfuse Dependency for Session ID Grouping in Response API

Open
#270 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good first issue
Dominant language
Python
Stars
18
Forks
10
Avg merge
2d 20h
Merged PRs (30d)
14

Description

Currently, in the Response API, we derive the session_id from Langfuse by querying it using the previous response_id, as shown below:

if response_id:
    traces = self.langfuse.fetch_traces(tags=response_id).data
    if traces:
        self.session_id = traces[0].session_id

This approach introduces an unnecessary runtime dependency on Langfuse, solely to group related traces under the same session for visualization purposes.

OpenAI does not currently provide a native conversation ID for API responses, which complicates session tracking.
We are in discussions with OpenAI to potentially add support for a conversation_id or similar identifier at their end which we can pass to langfuse as session_id.

Alternative: Maintain the session or conversation-level grouping within the Glific flow context itself, so that Langfuse becomes an observer rather than a source of truth for session identity.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue identifies the Response API path and the existing Langfuse trace lookup as the entry point; no file or test is named. First map where response_id and session_id are managed, then verify that session grouping remains consistent without a runtime Langfuse lookup.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, observability
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.