Skip to content

Conversation

@LifeJiggy
Copy link

@LifeJiggy LifeJiggy commented Oct 10, 2025

✨ Persistent Conversation Memory with Vector Database

This PR introduces long-term memory to Qwen-Agent by leveraging vector database storage, enabling context retention across sessions and significantly enhancing conversational continuity.


🚀 Features & Improvements

  • New Feature: ConversationMemory class powered by ChromaDB for efficient vector-based storage and retrieval.
  • Agent Upgrade: Added memory_cfg parameter to both Agent and Assistant classes for easy configuration.
  • Persistence: Store and retrieve conversations using vector similarity, ensuring relevant context is always available.
  • Testing: Comprehensive test coverage for new memory capabilities.
  • Documentation: README updated, plus practical usage example.
  • Dependencies: chromadb added as an optional dependency (backward compatible).

🧑‍💻 Usage Example

from qwen_agent.agents import Assistant

bot = Assistant(
    llm={'model': 'qwen-turbo', 'model_type': 'qwen_dashscope'},
    memory_cfg={'persist_dir': './memory_db', 'collection_name': 'conversations'}
)

# Conversations are now remembered across sessions!

🌟 Benefits

  • Seamlessly maintains context in long or multi-session conversations.
  • Improves agent continuity and overall user experience.
  • Robust and production-ready, with proper error handling.
  • Fully optional: no breaking changes, easy opt-in.

🧪 Testing

  • All existing tests pass.
  • New tests for persistent memory (test_conversation_memory).
  • Example script included: examples/assistant_with_memory.py.

📦 Installation

pip install "qwen-agent[memory]"

Feedback, questions, and suggestions are welcome!

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