Skip to content

fix: store user messages in the chat history in tutorial 48 - #497

Open
pcbeingused333 wants to merge 1 commit into
deepset-ai:mainfrom
pcbeingused333:fix/tutorial-48-user-messages
Open

pcbeingused333 wants to merge 1 commit into
deepset-ai:mainfrom
pcbeingused333:fix/tutorial-48-user-messages

Conversation

@pcbeingused333

Copy link
Copy Markdown

Fixes the conversational pipeline in tutorial 48 (Conversational RAG Agent) losing the user's questions.

Root cause: #447 removed the OutputAdapter (message_joiner) from this tutorial and connected llm.replies straight to message_writer.messages. The writer then stores only the assistant replies, so after two turns the chat history holds two assistant messages and no user message, and the second prompt sent to the LLM no longer contains the first question. The notebook text still says the message_joiner merges the user message with the reply, and the stored outputs still show both roles.

Fix: join the prompt and the replies with core ListJoiner(list[ChatMessage]) (not deprecated, no unsafe=True) before message_writer, and refresh the stale pipeline-description output. The Agent pipeline already writes agent.messages (user + assistant) and is unchanged.

Test: ran the notebook's chat-history cells with a stub generator, two turns, and checked the stored roles and that the second LLM call includes the first question.

  • Before: stored roles ['assistant', 'assistant'], assertion fails.
  • After: ['user', 'assistant', 'user', 'assistant'], passes.

Reproduction: haystack-ai 3.5.0 and haystack-experimental 0.19.0.post1; build the first pipeline from the notebook, run two queries with a chat_history_id, then call message_store.retrieve_messages(chat_history_id=..., last_k=None).


This contribution was prepared with the help of an AI coding assistant (Claude Code); the change and the test were produced by that session and submitted by the account holder.

The first pipeline only connected llm.replies to message_writer after the OutputAdapter was removed in deepset-ai#447, so the chat history kept only assistant messages and follow-up prompts lost earlier questions. Join the prompt and the replies with ListJoiner before writing.
@pcbeingused333
pcbeingused333 requested a review from a team as a code owner November 23, 2026 22:20
@review-notebook-app

Copy link
Copy Markdown

Review Notebooks

Notebooks changed:

Review visual diffs and comment on any notebook cell. All comments sync back to this PR.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant