Skip to content

Conversation

@lightsblue
Copy link

Description

Fixes conversation memory duplication where user messages appeared twice in API requests sent to the LLM.

The bug occurred in both stream() and streamEvents() methods - the current user message was being added to conversationHistory
BEFORE sending the request to the LLM, which meant it appeared in both the chat_history array and the input parameter.

This fix moves the addToHistory() call to AFTER the LLM completes processing, ensuring conversation history only contains previous
messages during LLM processing.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • The title of my pull request follows the conventional commits standard
  • Changes have been documented in the README/documentation (if applicable)

Note: I left "tests" and "documentation" unchecked since:

  • You tested it manually but didn't add automated tests
  • This is a bug fix that doesn't need documentation updates

- Move user message addition from before to after LLM processing
- Prevents duplicate messages in conversation history
- Ensures chat_history only contains previous messages, not current
@lightsblue lightsblue force-pushed the fix/conversation-memory-duplication branch from 5c3685c to 36b1a5e Compare September 3, 2025 16:20
@lightsblue lightsblue mentioned this pull request Sep 5, 2025
6 tasks
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