I'm speaking as the agency taking over, so let me say upfront: I won't trash the old agency in this post, because the receiving side always looks right and that's usually a lie.
The state of the project we took over was this: there was code, it worked, and nobody knew what it did.
We completed the process in three weeks. I'll write down how we did it, because concrete accounts of handovers are rare.
Week one: we didn't touch anything. We just read, ran, and took notes. The client objected to this week, saying "we're paying but there's no progress." They were right but also wrong.
Week two: we only documented. How the system is set up, which services are used, what each part connects to. We also listed known issues.
Week three: we made the first change. Something small, visible, and reversible. The goal wasn't to fix things, but to test the process.
We suffered in every handover where this order was broken. In all handovers where they started developing immediately, we hit a wall in the second month.