async def test_set_messages(chat_store: SQLAlchemyChatStore):
    """Test setting messages (replacing existing ones)."""
    # Add initial messages
    await chat_store.add_message(
        "replace_user", ChatMessage(role="user", content="initial")
    )

    # Replace with new set
    new_messages = [
        ChatMessage(role="user", content="replaced1"),
        ChatMessage(role="assistant", content="replaced2"),
    ]
    await chat_store.set_messages("replace_user", new_messages)

    # Verify replacement
    messages = await chat_store.get_messages("replace_user")
    assert len(messages) == 2
    assert [m.content for m in messages] == ["replaced1", "replaced2"]
Test setting messages (replacing existing ones).
llama-index-core/tests/storage/chat_store/test_sql.py