Skip to content

[Bug]: Chat History and Dirty-Mark Written to Wrong Session in Multi-Session Stream Requests #575

Description

@Srejoye

Summary

Description

POST /ask/stream supports multiple session IDs via data.session_ids. The handler iterates over session_id_list and retrieves candidates from each session (lines 3862–3964).

Affected Files

  • rag-service/main.py lines 3862–4148 (ask_question_stream, post-loop session_id usage)

Steps to reproduce

POST /ask/stream
{
  "question": "summarize",
  "session_ids": ["uuid-A", "uuid-B"],
  "session_secrets": ["secret-A", "secret-B"]
}

After the call, session A's chat history is empty; session B contains the message twice (if retrieved from both sessions).

Expected behavior

After the loop, the code uses the bare Python variable session_id — which holds the last value assigned during the loop — for all subsequent operations including:

  • append_chat_exchange(current_session, ...) (evidence-gate refusal path)
  • _mark_session_dirty(session_id)
  • sessions.get(session_id) for persisting the final answer

Actual behavior

When a request spans two sessions (e.g. session_ids: ["A", "B"]), every chat message and dirty mark is written to session "B" regardless of which session actually provided the answer context. Session "A"'s history is never updated.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requestfeatureA new feature or improvementfrontendFrontend-related workquestionFurther information is requestedrag-serviceFastAPI / model service work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions