You've started your game, and when you started you were going with a pre-packaged adventure. However, now that you're in play something is off. Perhaps you don't like the way the adventure is written to go - even if you still like the idea of the adventure. Perhaps your PCs have done enough things unexpected by the adventure author that something is broken. Perhaps you just want to stretch your wings as a GM and add some personal embellishments. Whatever your reason, today we're going to talk about what to keep in mind while doing that.
Don't Erase The Past
Whatever your reason for changing from things as written, it's important that you remember what has already been established. Your players won't know if you change things going forward, but if you change things in the past it's going to put them in a weird position. Unlike with comic books and other creative mediums, we can't retcon the game. If you think things are that broken you are better off re-starting all together.
That said, if you have a second session to run - or whatever number you are on - that means the previous ones couldn't have been that unsuccessful, so why destroy established entertaining material? Instead, just remember what has been established and use that as your building blocks for going forward.
We have complete control to change where the game will go, but what has already happened? Leave it in the past.
Don't Be Afraid to Steal
Regardless of your reason for breaking from the established adventure, don't be afraid to steal anything that you do like from it. Maybe it's a map for a castle, an NPC, a side story, or just a particular encounter. It doesn't matter, you can take it. Honestly, you can take from anything you want for your game. Unless you're streaming the game to an audience with intent to monetize, no one is going to care about your private game, so take what you want.
Your PCs Goals Are Probably Set Already
The big tasks in front of your PCs are likely already set by what already happened. Just as we can't change the past, we have to acknowledge these goals. If you're doing Lost Mine of Phandelver for example, your PCs likely are set to look for the titular lost mine. If you're doing L5R's Topaz Championship, the PCs probably want to get to the Championship to do their part.
Now, recognizing that your PCs have these goals doesn't mean you can't change them. You just need to make sure you acknowledge them and give a reason for why those goals may be changing. How that works is up to you.
You Don't Need To Tell Your Players
If you promised someone you were going to run X adventure by the book, then maybe you should tell them. After all, you're breaking the set expectation. Otherwise, don't worry about telling your players. You can say you're trying some custom content, or you can just let them explore and run into it. No one is going to know what changes you made to the game unless they've run or read the adventure before. If they have run or read the adventure before, the book itself is going to tell you to change things to keep them in the dark too.
Ultimately, as long as the game goes forward and is fun no one will care if you're running from a book or running your own custom stuff. So do what makes you happy, and keep the game fun.