Memori icon indicating copy to clipboard operation
Memori copied to clipboard

Fix multi-turn conversation ingestion for AzureOpenAI

Open lindseystead opened this issue 3 weeks ago • 2 comments

Fixes #83

This PR fixes an issue where only the first conversation turn was being ingested when using AzureOpenAI with Memori.

Root cause

On subsequent invocations, conversation_id was not reliably resolved early enough in the request lifecycle. This prevented prior messages from being injected and caused new messages to not consistently be written to the same conversation.

Changes

  • Ensured session_id and conversation_id are resolved early in inject_conversation_messages so prior messages can be injected correctly
  • Used idempotent conversation.create() to safely retrieve or create the active conversation within the timeout window
  • Ensured only new messages are written while injected history is excluded to prevent duplication
  • Added logging to surface when memory is written and which conversation/session is used
  • Added test coverage verifying all conversation turns are ingested

Result

  • Every user message is ingested on every turn
  • Every assistant response is ingested on every turn
  • Previous messages are injected for context without duplication
  • Public APIs and AzureOpenAI usage remain unchanged

lindseystead avatar Dec 12 '25 06:12 lindseystead

Hi @lindseystead Thanks for catching this and making a contribution. Do you mind creating an issue(bug) for this PR? We will review the issue and PR and provide feedback if necessary.

Thanks again!

devwdave avatar Dec 12 '25 19:12 devwdave

Created issue #233 as requested. The issue documents the bug and links to this PR.

lindseystead avatar Dec 12 '25 23:12 lindseystead