Conversation Summary Buffer Memory is reset, what should I do?

hi i’m developing RAG llm with streamlit
but i got a problem

so, i use ConversationSummaryBufferMemory + ConversationalRetrievalChain

But I have to remember the previous conversation, but it gets reset every time I chat

This is my code

msgs = StreamlitChatMessageHistory(key = 'chat_history')

memory = ConversationSummaryBufferMemory(llm = llm , max_token_limit=50 , memory_key='chat_history', memory = msgs,
                                          return_messages=False)

qa_chain = ConversationalRetrievalChain.from_llm(
    llm, 
    retriever=vectorstore2,
    memory=memory,
    get_chat_history = lambda h:h,
    verbose=True,
    return_source_documents=False
)
for msg in msgs.messages:
    st.chat_message(avatars[msg.type]).write(msg.content)